Ein Typ-to-Speech-API (Text-to-Speech) von Microsoft Edge. Dieses Paket ist sowohl mit Node.js- als auch mit Browserumgebungen kompatibel, wodurch es für verschiedene Anwendungsfälle vielseitig ist.
https://www.npmjs.com/package/edge-tts-client
Um das Paket zu installieren, führen Sie aus:
npm install edge-tts-client import { EdgeTTSClient , ProsodyOptions , OUTPUT_FORMAT } from 'edge-tts-client' ;
// Initialize the client
const ttsClient = new EdgeTTSClient ( ) ;
// Set metadata for synthesis
await ttsClient . setMetadata ( 'en-US-GuyNeural' , OUTPUT_FORMAT . AUDIO_24KHZ_48KBITRATE_MONO_MP3 ) ;
// Define SSML options
const options = new ProsodyOptions ( ) ;
options . pitch = 'medium' ;
options . rate = 1.2 ;
options . volume = 90 ;
// Synthesize text to a stream
const stream = ttsClient . toStream ( 'Hello, world!' , options ) ;
// Handle the audio stream
stream . on ( 'data' , ( audioChunk ) => {
console . log ( 'Received audio chunk:' , audioChunk ) ;
} ) ;
stream . on ( 'end' , ( ) => {
console . log ( 'Synthesis complete.' ) ;
} ) ; EdgeTTSClientDie Hauptklasse für die Interaktion mit Edge TTs.
setMetadata(voiceName: string, outputFormat: OUTPUT_FORMAT, voiceLocale?: string): Promise<void>
toStream(input: string, options?: ProsodyOptions): EventEmitter
close(): void
ProsodyOptionsDefiniert die Prosody -Optionen für die SSML -Synthese:
pitch : Tonhöhe der Stimme (z. B. 'medium' , 'high' ).rate : Geschwindigkeit der Sprache (z. B. 1.0 , 1.2 ).volume : Volumen des Audios (zB 90 , 'loud' ).OUTPUT_FORMATEin Auflauf, der die verfügbaren Ausgangsformate definiert, z. B.:
AUDIO_24KHZ_48KBITRATE_MONO_MP3WEBM_24KHZ_16BIT_MONO_OPUS Um das Projekt zu erstellen, rennen Sie:
npm run buildTests mit Vitest durchführen:
npm run test Beiträge sind willkommen! Bitte eröffnen Sie ein Problem oder senden Sie eine Pull -Anfrage für Änderungen oder Verbesserungen.