### Basic Usage Example Source: https://www.npmjs.com/package/text2wav?activeTab=readme Example demonstrating API usage and CLI file redirection. ```javascript (async () => { const text2wav = require('text2wav') let out = await text2wav('test') // out is of type Uint8Array const assert = require('assert') assert.equal(out[0], 82) //R assert.equal(out[1], 73) //I assert.equal(out[2], 70) //F assert.equal(out[3], 70) //F })() ``` ```bash text2wav test > test.wav ``` -------------------------------- ### Install text2wav Source: https://www.npmjs.com/package/text2wav?activeTab=readme Installation commands for the library or the command-line interface. ```bash npm i -S text2wav ``` ```bash npm i -g text2wav ``` -------------------------------- ### text2wav Installation Source: https://www.npmjs.com/package/text2wav?activeTab=dependents Instructions for installing the text2wav library using npm. ```APIDOC ## Installation ### Description Installs the text2wav library for use in Node.js projects or as a global CLI tool. ### Method `npm install` ### Endpoints `npm` package registry ### Usage #### For API usage: ```bash npm i -S text2wav ``` #### For CLI usage: ```bash npm i -g text2wav ``` ``` -------------------------------- ### Basic API Usage Example Source: https://www.npmjs.com/package/text2wav?activeTab=dependencies A simple example demonstrating the basic API usage and asserting the first few bytes of the WAV output. ```javascript (async () => { const text2wav = require('text2wav') let out = await text2wav('test') // out is of type Uint8Array const assert = require('assert') assert.equal(out[0], 82) //R assert.equal(out[1], 73) //I assert.equal(out[2], 70) //F assert.equal(out[3], 70) //F })() ``` -------------------------------- ### Basic CLI Usage Example Source: https://www.npmjs.com/package/text2wav?activeTab=dependencies Example of using the CLI to convert text to speech and redirect the output to a WAV file. ```bash text2wav test > test.wav ``` -------------------------------- ### Basic CLI Usage Example Source: https://www.npmjs.com/package/text2wav?activeTab=code Example of using the text2wav CLI to convert text to speech and redirect the output to a WAV file. ```bash text2wav test > test.wav ``` -------------------------------- ### Advanced Usage Examples Source: https://www.npmjs.com/package/text2wav?activeTab=readme Examples for specific languages, voice variants, and punctuation handling. ```javascript let out = await text2wav('测试', {voice: 'zh'}) ``` ```bash text2wav '测试' -v zh > test.wav ``` ```javascript let out = await text2wav('test', {voice: 'en+whisper'}) ``` ```bash text2wav test -v en+whisper > test.wav ``` ```javascript let out = await text2wav('"test", I say.', {punct: '"'}) ``` ```bash text2wav '"test", I say.' --punct='"' > test.wav ``` -------------------------------- ### Install text2wav for CLI usage Source: https://www.npmjs.com/package/text2wav?activeTab=dependencies Use this command to install the text2wav module globally, making its command-line interface available. ```bash npm i -g text2wav ``` -------------------------------- ### Install text2wav for API usage Source: https://www.npmjs.com/package/text2wav?activeTab=dependencies Use this command to install the text2wav module as a dependency for your Node.js project. ```bash npm i -S text2wav ``` -------------------------------- ### CLI Usage with Chinese Voice Source: https://www.npmjs.com/package/text2wav?activeTab=dependencies Example of using the CLI to synthesize speech in Chinese by specifying the 'zh' voice. ```bash text2wav '测试' -v zh > test.wav ``` -------------------------------- ### CLI Usage with Whisper Variant Source: https://www.npmjs.com/package/text2wav?activeTab=code Example of using the text2wav CLI with a specific voice variant, 'en+whisper'. ```bash text2wav test -v en+whisper > test.wav ``` -------------------------------- ### API Usage to Speak Punctuation Source: https://www.npmjs.com/package/text2wav?activeTab=dependencies Example of using the API to speak the punctuation marks within the text by setting the 'punct' option. ```javascript let out = await text2wav('"test", I say.', {punct: '"'}) ``` -------------------------------- ### CLI Usage to Speak Punctuation Source: https://www.npmjs.com/package/text2wav?activeTab=code Example of using the text2wav CLI to speak punctuation marks by specifying the '--punct' option. ```bash text2wav '"test", I say.' --punct='"' > test.wav ``` -------------------------------- ### API Usage with Chinese Voice Source: https://www.npmjs.com/package/text2wav?activeTab=dependencies Example of using the API to synthesize speech in Chinese by specifying the 'zh' voice. ```javascript let out = await text2wav('测试', {voice: 'zh'}) ``` -------------------------------- ### CLI Usage with Whisper Variant Source: https://www.npmjs.com/package/text2wav?activeTab=dependencies Example of using the CLI to synthesize speech with the 'whisper' variant of the English voice. ```bash text2wav test -v en+whisper > test.wav ``` -------------------------------- ### CLI Usage to Speak Punctuation Source: https://www.npmjs.com/package/text2wav?activeTab=dependencies Example of using the CLI to speak the punctuation marks within the text by specifying the '--punct' option. ```bash text2wav '"test", I say.' --punct='"' > test.wav ``` -------------------------------- ### API Usage with Whisper Variant Source: https://www.npmjs.com/package/text2wav?activeTab=dependencies Example of using the API to synthesize speech with the 'whisper' variant of the English voice. ```javascript let out = await text2wav('test', {voice: 'en+whisper'}) ``` -------------------------------- ### CLI Usage Source: https://www.npmjs.com/package/text2wav?activeTab=dependencies Use the text2wav command-line interface to convert text to speech and output to stdout. ```bash text2wav [] ``` -------------------------------- ### text2wav CLI Usage Source: https://www.npmjs.com/package/text2wav?activeTab=dependencies Instructions for using the text2wav command-line interface. ```APIDOC ## text2wav CLI ### Description This section describes how to use the text2wav command-line tool to synthesize speech directly from your terminal. ### Method `text2wav []` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **text** (string) - Required - The text to be synthesized into speech. - **opts** (options) - Optional - Flags to configure speech synthesis. These correspond to the API options: - **-v, --voice** (string) - Use voice file of this name from _/espeak-ng-data_. A variant can be specified using +, such as af+m3. - **-a, --amplitude** (integer) - Amplitude, 0 to 200. - **-g, --wordGap** (integer) - Word gap. Pause between words, units of 10ms at the default speed. - **-k, --capital** (integer) - Indicate capital letters with: 1=sound, 2=the word "capitals", higher values = a pitch increase (try -k20). - **-l, --lineLength** (integer) - Line length. If not zero (which is the default), consider lines less than this length as end-of-clause. - **-p, --pitch** (integer) - Pitch adjustment, 0 to 99. - **-s, --speed** (integer) - Speed in words per minute. - **-b, --encoding** (<1|2|4>) - Input text encoding, 1=UTF8, 2=8 bit, 4=16 bit. - **-m, --hasTags** (boolean) - Indicates that the text contains SSML (Speech Synthesis Markup Language) tags or other XML tags. - **-z, --noFinalPause** (boolean) - No final sentence pause at the end of the text. - **--punct[=]** (string or boolean) - Speak the names of punctuation characters during speaking. If = is omitted, all punctuations are spoken. ### Request Example ```bash text2wav "This is a test." > output.wav text2wav "你好世界" -v zh > chinese.wav text2wav "Whispering test" -v en+whisper > whisper.wav text2wav 'Quote test' --punct='"' > quote.wav ``` ### Response #### Success Response (200) - **stdout** - The synthesized speech in WAV format is output to standard output. #### Response Example ```bash text2wav "Hello" > hello.wav ``` ``` -------------------------------- ### Use text2wav CLI Source: https://www.npmjs.com/package/text2wav?activeTab=readme Command line usage for generating WAV output to stdout. ```bash text2wav [] ``` -------------------------------- ### Compile espeak-ng Source: https://www.npmjs.com/package/text2wav?activeTab=readme Build instructions for compiling espeak-ng into JavaScript and WebAssembly. ```bash git clone https://github.com/espeak-ng/espeak-ng.git cd espeak-ng ./autogen.sh ./configure --without-async --with-extdict-zh --with-extdict-zhy --with-extdict-ru make cd src/ucd-tools/ ./autogen.sh make clean emconfigure ./configure emmake make cd ../.. emconfigure ./configure --without-async --without-mbrola --without-sonic --enable-shared=false emmake make src/espeak-ng mv src/espeak-ng src/espeak-ng.bc emcc -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s MODULARIZE=1 -s 'EXPORT_NAME="EspeakNg"' -o espeak-ng.js src/espeak-ng.bc echo // espeak-ng git hash `git rev-parse HEAD` >> espeak-ng.js ``` -------------------------------- ### text2wav CLI Usage Source: https://www.npmjs.com/package/text2wav?activeTab=code How to use the text2wav command-line interface to convert text to speech. ```APIDOC ## text2wav CLI ### Description Command-line interface for converting text to speech and outputting WAV audio to stdout. ### Method CLI Command ### Endpoint text2wav ### Parameters #### Arguments - **text** (string) - Required - The text to convert to speech. - **opts** (options) - Optional - Configuration options for speech synthesis. - **-v, --voice** (string) - Use voice file of this name from _/espeak-ng-data_. A variant can be specified using +, such as af+m3. Defaults to 'en'. - **-a, --amplitude** (integer) - Amplitude, 0 to 200. Defaults to 100. - **-g, --wordGap** (integer) - Word gap. Pause between words, units of 10ms at the default speed. - **-k, --capital** (integer) - Indicate capital letters with: 1=sound, 2=the word "capitals", higher values = a pitch increase (try -k20). - **-l, --lineLength** (integer) - Line length. If not zero (which is the default), consider lines less than this length as end-of-clause. - **-p, --pitch** (integer) - Pitch adjustment, 0 to 99. Defaults to 50. - **-s, --speed** (integer) - Speed in words per minute. Defaults to 175. - **-b, --encoding** (integer) - Input text encoding, 1=UTF8, 2=8 bit, 4=16 bit. Defaults to 1. - **-m, --hasTags** (boolean) - Indicates that the text contains SSML (Speech Synthesis Markup Language) tags or other XML tags. Defaults to false. - **-z, --noFinalPause** (boolean) - No final sentence pause at the end of the text. Defaults to false. - **--punct[=]** (string or boolean) - Speak the names of punctuation characters during speaking. If = is omitted, all punctuations are spoken. Defaults to false. ### Request Example ```bash text2wav "Hello, world!" -v en -s 150 > output.wav ``` ### Response #### Success Response (stdout) - **wavContent** (binary) - The WAV audio data is output to standard output. #### Response Example ```bash text2wav test > test.wav ``` ``` -------------------------------- ### text2wav CLI Usage Source: https://www.npmjs.com/package/text2wav?activeTab=dependents How to use the text2wav command-line interface to convert text to speech and output to stdout. ```APIDOC ## text2wav CLI ### Description Command-line interface for text2wav to convert text to speech and output WAV audio to stdout. ### Method `CLI Command` ### Endpoint `text2wav` ### Parameters #### Command Line Arguments - **text** (string) - Required - The input text to be converted to speech. - **opts** (flags) - Optional - Configuration options for the speech synthesis. #### Options Flags | API | CLI | type | default | description | |---|---|---|---|---| | voice | -v | string | en | Use voice file of this name from _/espeak-ng-data_. A variant can be specified using +, such as af+m3. | | amplitude | -a | integer | 100 | Amplitude, 0 to 200. | | wordGap | -g | integer | | Word gap. Pause between words, units of 10ms at the default speed. | | capital | -k | integer | | Indicate capital letters with: 1=sound, 2=the word "capitals", higher values = a pitch increase (try -k20). | | lineLength | -l | integer | | Line length. If not zero (which is the default), consider lines less than this length as end-of-clause. | | pitch | -p | integer | 50 | Pitch adjustment, 0 to 99. | | speed | -s | integer | 175 | Speed in words per minute. | | encoding | -b | <1|2|4> | 1 | Input text encoding, 1=UTF8, 2=8 bit, 4=16 bit. | | hasTags | -m | boolean | false | Indicates that the text contains SSML (Speech Synthesis Markup Language) tags or other XML tags. | | noFinalPause | -z | boolean | false | No final sentence pause at the end of the text. | | punct | --punct[=] | string or boolean | false | Speak the names of punctuation characters during speaking. | ### Request Example ```bash text2wav "Hello world" -v en -s 150 > output.wav ``` ### Response #### Success Response (stdout) - WAV audio content piped to stdout. #### Response Example ```bash text2wav test > test.wav ``` ``` -------------------------------- ### Compile espeak-ng for text2wav Source: https://www.npmjs.com/package/text2wav?activeTab=dependencies Commands to clone, configure, and compile the espeak-ng project to generate Javascript and WebAssembly libraries for text2wav. ```bash git clone https://github.com/espeak-ng/espeak-ng.git cd espeak-ng ./autogen.sh ./configure --without-async --with-extdict-zh --with-extdict-zhy --with-extdict-ru make cd src/ucd-tools/ ./autogen.sh make clean emconfigure ./configure emmake make cd ../.. emconfigure ./configure --without-async --without-mbrola --without-sonic --enable-shared=false emmake make src/espeak-ng mv src/espeak-ng src/espeak-ng.bc emcc -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s MODULARIZE=1 -s 'EXPORT_NAME="EspeakNg"' -o espeak-ng.js src/espeak-ng.bc echo // espeak-ng git hash `git rev-parse HEAD` >> espeak-ng.js ``` -------------------------------- ### text2wav(text, opts) Source: https://www.npmjs.com/package/text2wav?activeTab=readme Converts input text into a WAV audio buffer using specified synthesis options. ```APIDOC ## text2wav(text, opts) ### Description Converts the provided text string into a WAV audio format based on the provided configuration options. ### Method Async Function ### Parameters #### Request Body - **text** (string) - Required - The text content to be synthesized. - **opts** (object) - Optional - Configuration object for speech synthesis: - **voice** (string) - Optional - Voice name from /espeak-ng-data (default: 'en'). - **amplitude** (integer) - Optional - Amplitude, 0 to 200 (default: 100). - **wordGap** (integer) - Optional - Pause between words in 10ms units. - **capital** (integer) - Optional - Indicate capital letters (1=sound, 2=word "capitals", higher=pitch increase). - **lineLength** (integer) - Optional - Line length for end-of-clause detection. - **pitch** (integer) - Optional - Pitch adjustment, 0 to 99 (default: 50). - **speed** (integer) - Optional - Speed in words per minute (default: 175). - **encoding** (integer) - Optional - Input text encoding (1=UTF8, 2=8 bit, 4=16 bit, default: 1). - **hasTags** (boolean) - Optional - Indicates if text contains SSML/XML tags (default: false). - **noFinalPause** (boolean) - Optional - Disable final sentence pause (default: false). - **punct** (string/boolean) - Optional - Speak punctuation names (default: false). ### Request Example ```javascript const text2wav = require('text2wav'); let out = await text2wav('Hello World', { voice: 'en', speed: 175 }); ``` ### Response #### Success Response (200) - **Uint8Array** - The resulting WAV audio content. #### Response Example ```javascript // out is a Uint8Array containing the WAV file data ``` ``` -------------------------------- ### API Usage in Javascript Source: https://www.npmjs.com/package/text2wav?activeTab=dependencies Import the text2wav module in your Javascript code. The function returns a Uint8Array containing the WAV audio data. ```javascript const text2wav = require('text2wav') let out = await text2wav([,]) ``` -------------------------------- ### API Usage in Typescript Source: https://www.npmjs.com/package/text2wav?activeTab=dependencies Import the text2wav module in your Typescript code. The function returns a Uint8Array containing the WAV audio data. ```typescript import text2wav = require('text2wav') let out = await text2wav([,]) ``` -------------------------------- ### Use text2wav API Source: https://www.npmjs.com/package/text2wav?activeTab=readme Basic usage patterns for the text2wav API in JavaScript and TypeScript. ```javascript const text2wav = require('text2wav') let out = await text2wav([,]) ``` ```typescript import text2wav = require('text2wav') let out = await text2wav([,]) ``` -------------------------------- ### text2wav API Usage Source: https://www.npmjs.com/package/text2wav?activeTab=dependencies How to use the text2wav library within your Node.js or TypeScript projects. ```APIDOC ## text2wav API ### Description This section details how to integrate the text2wav library into your JavaScript or TypeScript applications to synthesize speech from text. ### Method `text2wav(text[, opts])` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **text** (string) - Required - The text to be synthesized into speech. - **opts** (object) - Optional - Configuration options for speech synthesis. - **voice** (string) - Optional - Specifies the voice file to use (e.g., 'en', 'zh', 'en+whisper'). Defaults to 'en'. - **amplitude** (integer) - Optional - Amplitude of the speech, from 0 to 200. Defaults to 100. - **wordGap** (integer) - Optional - Pause between words in units of 10ms. - **capital** (integer) - Optional - How to indicate capital letters (e.g., 1 for sound, 2 for 'capitals', higher values for pitch increase). - **lineLength** (integer) - Optional - If not zero, considers lines shorter than this length as end-of-clause. - **pitch** (integer) - Optional - Pitch adjustment, from 0 to 99. Defaults to 50. - **speed** (integer) - Optional - Speed in words per minute. Defaults to 175. - **encoding** (string) - Optional - Input text encoding ('1' for UTF8, '2' for 8-bit, '4' for 16-bit). Defaults to '1'. - **hasTags** (boolean) - Optional - Indicates if the text contains SSML or XML tags. Defaults to false. - **noFinalPause** (boolean) - Optional - Suppresses the final sentence pause. Defaults to false. - **punct** (string or boolean) - Optional - Specifies punctuation to be spoken. If a string, speaks that punctuation; if true, speaks all punctuation. Defaults to false. ### Request Example ```javascript const text2wav = require('text2wav'); (async () => { let out = await text2wav('Hello, world!', { voice: 'en', speed: 150 }); // 'out' is of type Uint8Array containing the WAV audio data })(); ``` ### Response #### Success Response (200) - **wav_data** (Uint8Array) - The synthesized speech in WAV format. #### Response Example ```javascript // Example of how to handle the Uint8Array output // (Actual binary data will be returned, this is a conceptual representation) // const audioData = await text2wav('Sample text'); // console.log(audioData.length); // Output: number of bytes in the WAV file ``` ``` -------------------------------- ### text2wav API Usage Source: https://www.npmjs.com/package/text2wav?activeTab=dependents How to use the text2wav API in Javascript and Typescript to convert text to speech. ```APIDOC ## text2wav API ### Description Converts text to a WAV audio format using a self-contained Node.js module. ### Method `POST` (conceptual, as it's a function call) ### Endpoint `require('text2wav')` ### Parameters #### Function Parameters - **text** (string) - Required - The input text to be converted to speech. - **opts** (object) - Optional - Configuration options for the speech synthesis. #### Options Object (`opts`) | API | CLI | type | default | description | |---|---|---|---|---| | voice | -v | string | en | Use voice file of this name from _/espeak-ng-data_. A variant can be specified using +, such as af+m3. | | amplitude | -a | integer | 100 | Amplitude, 0 to 200. | | wordGap | -g | integer | | Word gap. Pause between words, units of 10ms at the default speed. | | capital | -k | integer | | Indicate capital letters with: 1=sound, 2=the word "capitals", higher values = a pitch increase (try -k20). | | lineLength | -l | integer | | Line length. If not zero (which is the default), consider lines less than this length as end-of-clause. | | pitch | -p | integer | 50 | Pitch adjustment, 0 to 99. | | speed | -s | integer | 175 | Speed in words per minute. | | encoding | -b | <1|2|4> | 1 | Input text encoding, 1=UTF8, 2=8 bit, 4=16 bit. | | hasTags | -m | boolean | false | Indicates that the text contains SSML (Speech Synthesis Markup Language) tags or other XML tags. | | noFinalPause | -z | boolean | false | No final sentence pause at the end of the text. | | punct | --punct[=] | string or boolean | false | Speak the names of punctuation characters during speaking. | ### Request Example ```javascript const text2wav = require('text2wav'); let out = await text2wav('Hello world', { voice: 'en', speed: 150 }); // out is of type Uint8Array ``` ### Response #### Success Response - **out** (Uint8Array) - The WAV audio content. #### Response Example ```javascript // Example response structure (Uint8Array content) // [82, 73, 70, 70, ...] ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.