Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
tts-narrator
Advanced tools
Readme
Generate narration with Text-To-Speech technology
The input is a script file in YAML format. Example script files can be found under test/fixtures.
The script file is structured in this way:
settings
: script settings
voice
: voice settings at script levelchapters
: array of chapter
settings
: chapter level voice settings that can override script level voice settingssections
: array of sections
settings
: section level voice settings that can override upper level voice settingsparagraphs
: array of paragraphs
settings
: paragraph level voice settings that can override upper level voice settingstext
: text content that needs to be converted into audioThe text
field of a paragraph can be pure text, or an SSML fragment. Multi-line strings are supported.
It has command line flags --play
and --no-play
to control whether generated MP3s should be played back.
This feature is supported by a dev dependency node-speaker.
If you use it as a library in your project, and would like to have the play back capability, you need to install node-speaker as a dependency in your project.
When running on MacOS, to avoid illegal hardware instruction
issue, try npm i speaker --mpg123-backend=openal
USAGE
$ tts-narrator [FILE]
ARGUMENTS
FILE path to the script file (.yml)
OPTIONS
-d, --debug output debug information
-h, --help show CLI help
-i, --interactive wait for key press before
entering each section
-k, --subscription-key=subscription-key Azure Speech service subscription
key
-o, --overwrite always overwrite previously
generated audio files
-p, --[no-]play play generated audio
-q, --quiet output warn and error information
only
-r, --region=region region of the text-to-speech
service
-s, --service=azure text-to-speech service to use
-v, --version show CLI version
--chapters=chapters list of chapters to process,
examples: "1-10,13,15", "4-"
--dry-run don't try to generate or play
audio
--sections=sections list of sections to process,
examples: "1-10,13,15", "5-"
--ssml display generated SSML
--subscription-key-env=subscription-key-env Name of the environment variable
that holds the subscription key
EXAMPLES
tts-narrator myscript.yml --play --interactive --service azure
--subscription-key-env SUBSCRIPTION_KEY --region australiaeast
tts-narrator ./test/fixtures/script3.yml -s azure --ssml -r australiaeast
--subscription-key-env=TTS_SUB_KEY --no-play --interactive -d
tts-narrator ./test/fixtures/script3.yml -s azure -r australiaeast
--subscription-key-env=TTS_SUB_KEY --quiet
tts-narrator ./test/fixtures/script3.yml
tts-narrator
• Const
scriptProcessorFlags: Object
CLI flags that are required/used by the ScriptProcessor.
Name | Type |
---|---|
chapters | IOptionFlag <undefined | string > |
debug | IBooleanFlag <boolean > |
dry-run | IBooleanFlag <boolean > |
interactive | IBooleanFlag <boolean > |
overwrite | IBooleanFlag <boolean > |
play | IBooleanFlag <boolean > |
quiet | IBooleanFlag <boolean > |
region | IOptionFlag <undefined | string > |
sections | IOptionFlag <undefined | string > |
service | IOptionFlag <undefined | string > |
ssml | IBooleanFlag <boolean > |
subscription-key | IOptionFlag <undefined | string > |
subscription-key-env | IOptionFlag <undefined | string > |
▸ getAudioFileDuration(filePath
): Promise
<number
>
Name | Type |
---|---|
filePath | string |
Promise
<number
>
▸ loadScript(scriptFilePath
): Promise
<NarrationScript
>
Name | Type |
---|---|
scriptFilePath | string |
Promise
<NarrationScript
>
▸ playMp3File(filePath
, infoLogger
): Promise
<void
>
Name | Type |
---|---|
filePath | string |
infoLogger | (msg : string ) => void |
Promise
<void
>
▸ saveScript(script
): Promise
<void
>
Name | Type |
---|---|
script | NarrationScript |
Promise
<void
>
▸ saveScript(script
, scriptFilePath
): Promise
<void
>
Name | Type |
---|---|
script | Script |
scriptFilePath | string |
Promise
<void
>
tts-narrator / AzureTtsService
↳ AzureTtsService
• new AzureTtsService()
▸ Protected
buildSpeakStartTag(voiceSettings
): string
Name | Type |
---|---|
voiceSettings | VoiceSettings |
string
BaseTtsService.buildSpeakStartTag
▸ Protected
buildVoiceStartTag(voiceSettings
): string
Name | Type |
---|---|
voiceSettings | VoiceSettings |
string
BaseTtsService.buildVoiceStartTag
▸ generateAudio(ssml
, options
): Promise
<any
>
Name | Type |
---|---|
ssml | string |
options | AzureAudioGenerationOptions |
Promise
<any
>
▸ generateSSML(paragraph
): Promise
<string
>
Name | Type |
---|---|
paragraph | NarrationParagraph |
Promise
<string
>
▸ Protected
generateSsmlWithoutValidation(paragraph
): Object
Name | Type |
---|---|
paragraph | NarrationParagraph |
Object
Name | Type |
---|---|
lineOffset | number |
ssml | string |
BaseTtsService.generateSsmlWithoutValidation
▸ Protected
validateXML(xml
, lineOffset
): void
Name | Type |
---|---|
xml | string |
lineOffset | number |
void
tts-narrator / BaseTtsService
BaseTtsService
• new BaseTtsService()
▸ Protected
buildSpeakStartTag(voiceSettings
): string
Name | Type |
---|---|
voiceSettings | VoiceSettings |
string
▸ Protected
buildVoiceStartTag(voiceSettings
): string
Name | Type |
---|---|
voiceSettings | VoiceSettings |
string
▸ generateAudio(_ssml
, _options
): Promise
<void
>
Name | Type |
---|---|
_ssml | string |
_options | AudioGenerationOptions |
Promise
<void
>
▸ generateSSML(paragraph
): Promise
<string
>
Name | Type |
---|---|
paragraph | NarrationParagraph |
Promise
<string
>
▸ Protected
generateSsmlWithoutValidation(paragraph
): Object
Name | Type |
---|---|
paragraph | NarrationParagraph |
Object
Name | Type |
---|---|
lineOffset | number |
ssml | string |
▸ Protected
validateXML(xml
, lineOffset
): void
Name | Type |
---|---|
xml | string |
lineOffset | number |
void
tts-narrator / NarrationChapter
• new NarrationChapter(chapter
, index
, script
)
Name | Type |
---|---|
chapter | Chapter |
index | number |
script | NarrationScript |
• Protected
chapter: Chapter
• index: number
• script: NarrationScript
• sections: NarrationSection
[]
• get
key(): string
string
• get
settings(): VoiceSettings
▸ getSectionByKey(key
): undefined
| NarrationSection
Name | Type |
---|---|
key | string |
undefined
| NarrationSection
tts-narrator / NarrationParagraph
• new NarrationParagraph(paragraph
, index
, section
, chapter
, script
)
Name | Type |
---|---|
paragraph | Paragraph |
index | number |
section | NarrationSection |
chapter | NarrationChapter |
script | NarrationScript |
• Optional
audioFilePath: string
Path of the generated audio file. Only for in-memory processing, not supposed to be stored in file.
• chapter: NarrationChapter
• index: number
• Protected
paragraph: Paragraph
• script: NarrationScript
• section: NarrationSection
• get
key(): string
string
• get
settings(): VoiceSettings
• get
text(): string
string
tts-narrator / NarrationScript
• new NarrationScript(script
, scriptFilePath
)
Name | Type |
---|---|
script | Script |
scriptFilePath | string |
• chapters: NarrationChapter
[]
• Protected
script: Script
• scriptFilePath: string
• get
settings(): ScriptSettings
▸ export(): Script
▸ getChapterByKey(key
): undefined
| NarrationChapter
Name | Type |
---|---|
key | string |
undefined
| NarrationChapter
tts-narrator / NarrationSection
• new NarrationSection(section
, index
, chapter
, script
)
Name | Type |
---|---|
section | Section |
index | number |
chapter | NarrationChapter |
script | NarrationScript |
• chapter: NarrationChapter
• index: number
• paragraphs: NarrationParagraph
[]
• script: NarrationScript
• Protected
section: Section
• get
key(): string
string
• get
settings(): VoiceSettings
tts-narrator / ScriptProcessor
• new ScriptProcessor(scriptFilePath
, flags
, cliConsole?
)
Name | Type |
---|---|
scriptFilePath | string |
flags | Object |
cliConsole? | CliConsole <fn , fn , fn , fn > |
• Protected
_script: NarrationScript
• Protected
audioGenerationOptions: undefined
| AudioGenerationOptions
• Protected
chapterRange: undefined
| MultiRange
• Protected
cliConsole: CliConsole
<fn
, fn
, fn
, fn
>
• Protected
flags: Object
• Protected
scriptFilePath: string
• Protected
sectionRange: undefined
| MultiRange
• Protected
ttsService: TtsService
• get
script(): NarrationScript
▸ Protected
determineAudioFilePath(ssmlHash
, _paragraph
): Promise
<string
>
Name | Type |
---|---|
ssmlHash | string |
_paragraph | NarrationParagraph |
Promise
<string
>
▸ Protected
hash(ssml
, _paragraph
): string
Name | Type |
---|---|
ssml | string |
_paragraph | NarrationParagraph |
string
▸ Protected
initialiseTtsServiceIfNeeded(): Promise
<void
>
Promise
<void
>
▸ Protected
loadScript(): Promise
<void
>
Promise
<void
>
▸ Protected
parseRanges(): void
void
▸ Protected
processGeneratedAudioFile(audioFilePath
): Promise
<string
>
Name | Type |
---|---|
audioFilePath | string |
Promise
<string
>
▸ run(reconstructedcommandLine?
): Promise
<void
>
Name | Type |
---|---|
reconstructedcommandLine? | string |
Promise
<void
>
▸ runWithoutCatch(reconstructedcommandLine?
): Promise
<void
>
Name | Type |
---|---|
reconstructedcommandLine? | string |
Promise
<void
>
tts-narrator / TtsServiceType
• Azure = "azure"
tts-narrator / AudioGenerationOptions
AudioGenerationOptions
• outputFilePath: string
tts-narrator / AzureAudioGenerationOptions
↳ AzureAudioGenerationOptions
• outputFilePath: string
AudioGenerationOptions.outputFilePath
• Optional
serviceRegion: string
• Optional
subscriptionKey: string
tts-narrator / NarrationScriptFile / Chapter
NarrationScriptFile.Chapter
• Optional
key: string
• sections: Section
[]
• Optional
settings: VoiceSettings
tts-narrator / NarrationScriptFile / Paragraph
NarrationScriptFile.Paragraph
• Optional
key: string
• Optional
settings: VoiceSettings
• text: string
tts-narrator / NarrationScriptFile / Script
NarrationScriptFile.Script
• chapters: Chapter
[]
• settings: ScriptSettings
tts-narrator / NarrationScriptFile / Section
NarrationScriptFile.Section
• Optional
key: string
• paragraphs: Paragraph
[]
• Optional
settings: VoiceSettings
tts-narrator / ScriptSettings
• Optional
service: Azure
• Optional
voice: VoiceSettings
tts-narrator / TtsService
▸ generateAudio(ssml
, options
): Promise
<void
>
Name | Type |
---|---|
ssml | string |
options | AudioGenerationOptions |
Promise
<void
>
▸ generateSSML(paragraph
): Promise
<string
>
Name | Type |
---|---|
paragraph | NarrationParagraph |
Promise
<string
>
tts-narrator / VoiceSettings
• Optional
language: string
• Optional
name: string
tts-narrator / NarrationScriptFile
FAQs
Generate narration with Text-To-Speech technology
The npm package tts-narrator receives a total of 4 weekly downloads. As such, tts-narrator popularity was classified as not popular.
We found that tts-narrator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.