### Getting Sentence/Word Boundaries (Stream) (JavaScript) Source: https://github.com/migushthe2nd/msedgetts/blob/main/README.md This example shows how to enable sentence and word boundary metadata when streaming audio and provides an example of the expected metadata format. ```JavaScript import {MsEdgeTTS, OUTPUT_FORMAT} from "msedge-tts"; (async () => { const tts = new MsEdgeTTS(); await tts.setMetadata("en-US-AriaNeural", OUTPUT_FORMAT.WEBM_24KHZ_16BIT_MONO_OPUS, { wordBoundaryEnabled: true, sentenceBoundaryEnabled: true }); // as stream const {metadataStream} = await tts.toStream("Hi, how are you doing today hello hello hello?"); /* -> { "Metadata": [ { "Type": "SentenceBoundary", "Data": { "Offset": 1000000, "Duration": 35875000, "text": { "Text": "Hi, how are you doing today hello hello hello?", "Length": 46, "BoundaryType": "SentenceBoundary" } } } ] } */ // or as file const {metadataFilePath} = await tts.toFile("Hi, how are you?"); /* -> { "Metadata": [ ] } */ })(); ``` -------------------------------- ### Streaming Audio Output (JavaScript) Source: https://github.com/migushthe2nd/msedgetts/blob/main/README.md This example demonstrates how to initialize MsEdgeTTS, set the voice and output format, and stream the generated audio data using event listeners. ```JavaScript import {MsEdgeTTS, OUTPUT_FORMAT} from "msedge-tts"; const tts = new MsEdgeTTS(); await tts.setMetadata("en-IE-ConnorNeural", OUTPUT_FORMAT.WEBM_24KHZ_16BIT_MONO_OPUS); const {audioStream} = tts.toStream("Hi, how are you?"); audioStream.on("data", (data) => { console.log("DATA RECEIVED", data); // raw audio file data }); audioStream.on("close", () => { console.log("STREAM CLOSED"); }); ``` -------------------------------- ### Adjusting Voice Parameters (JavaScript) Source: https://github.com/migushthe2nd/msedgetts/blob/main/README.md This example illustrates how to modify voice parameters such as rate, pitch, and volume by passing an options object to the toStream method. ```JavaScript import {MsEdgeTTS, OUTPUT_FORMAT} from "msedge-tts"; (async () => { const tts = new MsEdgeTTS(); await tts.setMetadata("en-US-AriaNeural", OUTPUT_FORMAT.WEBM_24KHZ_16BIT_MONO_OPUS); const {audioStream} = await tts.toStream("Hi, how are you?", {rate: 0.5, pitch: "+200Hz"}); })(); ``` -------------------------------- ### Writing Audio to File (JavaScript) Source: https://github.com/migushthe2nd/msedgetts/blob/main/README.md This snippet shows how to use the MsEdgeTTS library to generate audio and save it directly to a specified file path. ```JavaScript import {MsEdgeTTS, OUTPUT_FORMAT} from "msedge-tts"; (async () => { const tts = new MsEdgeTTS(); await tts.setMetadata("en-US-AriaNeural", OUTPUT_FORMAT.WEBM_24KHZ_16BIT_MONO_OPUS); const {audioFilePath} = await tts.toFile("./tmpfolder", "Hi, how are you?"); })(); ``` -------------------------------- ### Using Custom HTTP Agent (JavaScript) Source: https://github.com/migushthe2nd/msedgetts/blob/main/README.md This snippet demonstrates how to configure the MsEdgeTTS client to use a custom HTTP agent, such as a proxy agent, during initialization. ```JavaScript import {MsEdgeTTS, OUTPUT_FORMAT} from "msedge-tts"; import {SocksProxyAgent} from 'socks-proxy-agent'; (async () => { const agent = new SocksProxyAgent("socks://your-name%40gmail.com:abcdef12345124@br41.nordvpn.com") const tts = new MsEdgeTTS(agent); await tts.setMetadata("en-US-AriaNeural", OUTPUT_FORMAT.WEBM_24KHZ_16BIT_MONO_OPUS); const {audioStream} = await tts.toStream("Hi, how are you?"); })(); ``` -------------------------------- ### Default SSML Structure Source: https://github.com/migushthe2nd/msedgetts/blob/main/README.md This XML snippet shows the default SSML structure used by the MsEdgeTTS library. It supports the 'speak', 'voice', and 'prosody' elements for controlling speech output. ```XML ${input} ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.