edge tts client
1.0.2
ไคลเอ็นต์ที่ใช้ typeScript สำหรับการโต้ตอบกับ API ข้อความเป็นคำพูดของ Microsoft Edge (TTS) แพ็คเกจนี้เข้ากันได้กับทั้ง Node.js และ สภาพแวดล้อมของเบราว์เซอร์ ทำให้มีความหลากหลายสำหรับกรณีการใช้งานที่หลากหลาย
https://www.npmjs.com/package/edge-tts-client
ในการติดตั้งแพ็คเกจ Run:
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.' ) ;
} ) ; EdgeTTSClientคลาสหลักสำหรับการโต้ตอบกับ Edge TTS
setMetadata(voiceName: string, outputFormat: OUTPUT_FORMAT, voiceLocale?: string): Promise<void>
toStream(input: string, options?: ProsodyOptions): EventEmitter
close(): void
ProsodyOptionsกำหนดตัวเลือกฉันทลักษณ์สำหรับการสังเคราะห์ SSML:
pitch : Pitch of the Voice (เช่น 'medium' , 'high' )rate : ความเร็วของคำพูด (เช่น 1.0 , 1.2 )volume : ปริมาตรของเสียง (เช่น 90 , 'loud' )OUTPUT_FORMATenum ที่กำหนดรูปแบบผลลัพธ์ที่มีอยู่เช่น:
AUDIO_24KHZ_48KBITRATE_MONO_MP3WEBM_24KHZ_16BIT_MONO_OPUS เพื่อสร้างโครงการ Run:
npm run buildเพื่อทำการทดสอบด้วย Vitest:
npm run test ยินดีต้อนรับ! โปรดเปิดปัญหาหรือส่งคำขอดึงสำหรับการเปลี่ยนแปลงหรือการปรับปรุงใด ๆ