edge tts as a service
1.0.0
Microsoft Edge의 TTS Engine을 사용하여 텍스트 음성 기능을 제공하는 간단한 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
Response example:
{
"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 Demo는 원활한 TTS 상호 작용을위한 완벽한 기능적 프론트 엔드를 제공하므로 Edge-TTS 서비스를 쉽게 시연하고 사용자 친화적 인 인터페이스와 통합 할 수 있습니다.
Q : 올바른 음성을 어떻게 선택합니까?
A : /voices Endpoint를 사용하여 사용 가능한 모든 목소리의 목록을 얻으십시오. 로케일 및 성 속성에 따라 선택하십시오.
Q : 어떤 언어가 지원됩니까?
A : 영어, 중국어, 일본어 등을 포함한 여러 언어. /voices 엔드 포인트를 확인하십시오.
Q : 오디오 파일 형식은 무엇입니까?
A : 서비스는 MP3 오디오 파일을 생성합니다.
문제와 풀 요청을 환영합니다. PR을 제출하기 전에 :
MIT 라이센스