MsEdgeTTS
1.0.0
Un simple module de service de parole Azure qui utilise l'API Microsoft Edge Read à haute voix.
Support complet pour SSML Soutienne uniquement les types d'éléments speak , voice et prosody . Ce qui suit est l'objet SSML par défaut:
< speak version = " 1.0 " xmlns = " http://www.w3.org/2001/10/synthesis " xmlns : mstts = " https://www.w3.org/2001/mstts "
xml : lang = " ${this._voiceLang} " >
< voice name = " ${voiceName} " >
< prosody rate = " ${rate} " pitch = " ${pitch} " volume = " ${volume} " >
${input}
</ prosody >
</ voice >
</ speak >Une documentation sur le format SSML est disponible ici. Tous les formats audio pris en charge peuvent être trouvés ici.
Assurez-vous d'échapper / désinfecter les contributions de votre utilisateur! Utilisez une bibliothèque comme XML-Escape.
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 readable = tts . toStream ( "Hi, how are you?" ) ;
readable . on ( "data" , ( data ) => {
console . log ( "DATA RECEIVED" , data ) ;
// raw audio file data
} ) ;
readable . on ( "close" , ( ) => {
console . log ( "STREAM CLOSED" ) ;
} ) ; 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 filePath = await tts . toFile ( "./example_audio.webm" , "Hi, how are you?" ) ;
} ) ( ) ; 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 filePath = await tts . toFile ( "./example_audio.webm" , "Hi, how are you?" , { rate : 0.5 , pitch : "+200Hz" } ) ;
} ) ( ) ;Utilisez une implémentation HTTP.Agent personnalisée comme Https-Proxy-Agent ou Socks-Proxy-Agent.
import { SocksProxyAgent } from 'socks-proxy-agent' ;
( async ( ) => {
const agent = new SocksProxyAgent ( "socks://your-name%40gmail.com:[email protected]" )
const tts = new MsEdgeTTS ( agent ) ;
await tts . setMetadata ( "en-US-AriaNeural" , OUTPUT_FORMAT . WEBM_24KHZ_16BIT_MONO_OPUS ) ;
const filePath = await tts . toFile ( "./example_audio.webm" , "Hi, how are you?" ) ;
} ) ( ) ; Pour la documentation complète, consultez la documentation de l'API.
Cette bibliothèque ne prend en charge que les promesses.