edge tts as a service
1.0.0
Microsoft EdgeのTTSエンジンを使用してテキストツーチック機能を提供するシンプルなHTTPサービスで、RESTFUL APIを通じて複数の言語と声をサポートします。
英語| 中文
git clone https://github.com/doctoroyy/edge-tts-as-a-service
cd edge-tts-as-a-servicepip install -r requirements.txtpython main.pyこのサービスはhttp://localhost:5000で入手できます
docker build -t edge-tts-as-a-service .docker run -d -p 5000:5000 edge-tts-as-a-serviceサポートされているすべての音声オプションを取得します。
GET /voices
応答例:
{
"code" : 200 ,
"message" : " OK " ,
"data" : [
{
"Name" : " en-US-GuyNeural " ,
"ShortName" : " en-US-GuyNeural " ,
"Gender" : " Male " ,
"Locale" : " en-US "
},
// ... more voices
]
}テキストをスピーチに変換し、オーディオファイルをダウンロードします。
POST /tts
リクエストボディ:
{
"text" : " Hello, World! " ,
"voice" : " en-US-GuyNeural " , // Optional, defaults to "zh-CN-YunxiNeural"
"file_name" : " hello.mp3 " // Optional, defaults to "test.mp3"
}応答:
リアルタイム再生に適したストリーミング出力でテキストをスピーチに変換します。
POST /tts/stream
リクエストボディ:
{
"text" : " Hello, World! " ,
"voice" : " en-US-GuyNeural " // Optional, defaults to "zh-CN-YunxiNeural"
}応答:
import requests
# Get available voices
response = requests . get ( 'http://localhost:5000/voices' )
voices = response . json ()[ 'data' ]
# Text-to-Speech (Download)
data = {
"text" : "Hello, World!" ,
"voice" : "en-US-GuyNeural" ,
"file_name" : "output.mp3"
}
response = requests . post ( 'http://localhost:5000/tts' , json = data )
with open ( 'output.mp3' , 'wb' ) as f :
f . write ( response . content )
# Text-to-Speech (Streaming)
response = requests . post ( 'http://localhost:5000/tts/stream' , json = data , stream = True )
with open ( 'stream_output.mp3' , 'wb' ) as f :
for chunk in response . iter_content ( chunk_size = 8192 ):
f . write ( chunk ) # Get available voices
curl http://localhost:5000/voices
# Text-to-Speech (Download)
curl -X POST http://localhost:5000/tts
-H " Content-Type: application/json "
-d ' {"text":"Hello, World!", "voice":"en-US-GuyNeural"} '
--output output.mp3
# Text-to-Speech (Streaming)
curl -X POST http://localhost:5000/tts/stream
-H " Content-Type: application/json "
-d ' {"text":"Hello, World!", "voice":"en-US-GuyNeural"} '
--output stream_output.mp3すぐに使用できるフロントエンドインターフェイスをお探しですか?
?クイックリンク:React-Audio-Stream-Demo
このReactデモは、シームレスなTTS相互作用のための完全に機能的なフロントエンドを提供するため、Edge-TTSサービスをユーザーフレンドリーなインターフェイスと簡単に実証および統合できます。
Q:正しい声を選ぶにはどうすればよいですか?
A: /voicesエンドポイントを使用して、利用可能なすべての声のリストを取得します。ロケール属性と性別属性に基づいて選択します。
Q:どの言語がサポートされていますか?
A:英語、中国語、日本語などを含む複数の言語/voicesエンドポイントを確認してください。完全なリストを確認してください。
Q:オーディオファイル形式は何ですか?
A:サービスはMP3オーディオファイルを生成します。
問題とプルリクエストは大歓迎です。 PRを提出する前に、
MITライセンス