Spaces:
Sleeping
Sleeping
updtae
Browse files
main.py
CHANGED
@@ -6,9 +6,15 @@ import os
|
|
6 |
from enum import Enum
|
7 |
import uvicorn
|
8 |
import time
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
10 |
description = """
|
11 |
## [接口文档](/docs)
|
|
|
12 |
## 功能:
|
13 |
- 零样本文本到语音(TTS): 输入 5 秒的声音样本,即刻体验文本到语音转换。
|
14 |
|
@@ -31,6 +37,16 @@ async def add_process_time_header(request: Request, call_next):
|
|
31 |
app.mount("/static", StaticFiles(directory="static"), name="static")
|
32 |
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
@app.post("/tts")
|
35 |
async def tts(
|
36 |
voice: DefaultVoice = Form("新闻女士"),
|
|
|
6 |
from enum import Enum
|
7 |
import uvicorn
|
8 |
import time
|
9 |
+
try:
|
10 |
+
from model import text_to_speech
|
11 |
+
except:
|
12 |
+
def text_to_speech(voice, text):
|
13 |
+
return f"static/zh/{voice}.mp3"
|
14 |
+
|
15 |
description = """
|
16 |
## [接口文档](/docs)
|
17 |
+
## [效果演示](/)
|
18 |
## 功能:
|
19 |
- 零样本文本到语音(TTS): 输入 5 秒的声音样本,即刻体验文本到语音转换。
|
20 |
|
|
|
37 |
app.mount("/static", StaticFiles(directory="static"), name="static")
|
38 |
|
39 |
|
40 |
+
class Language(str, Enum):
|
41 |
+
en = "English"
|
42 |
+
zh = "中文"
|
43 |
+
|
44 |
+
|
45 |
+
class DefaultVoice(str, Enum):
|
46 |
+
voice1 = "新闻小说主播-女士"
|
47 |
+
voice2 = "温柔女士"
|
48 |
+
|
49 |
+
|
50 |
@app.post("/tts")
|
51 |
async def tts(
|
52 |
voice: DefaultVoice = Form("新闻女士"),
|
model.py
CHANGED
@@ -750,20 +750,9 @@ def clone_voice(user_voice,user_text,user_lang):
|
|
750 |
tprint(f'🆗CLONE COMPLETE,{round(time2-time1,4)}s')
|
751 |
return output_wav
|
752 |
|
753 |
-
|
754 |
-
class Language(str, Enum):
|
755 |
-
en = "English"
|
756 |
-
zh = "中文"
|
757 |
-
|
758 |
-
|
759 |
-
class DefaultVoice(str, Enum):
|
760 |
-
voice1 = "新闻小说主播-女士"
|
761 |
-
voice2 = "温柔女士"
|
762 |
-
|
763 |
-
|
764 |
def text_to_speech(voice, text):
|
765 |
language = lang_detector(text)
|
766 |
-
if language ==
|
767 |
voice = f"static/en/{voice}.mp3"
|
768 |
else:
|
769 |
voice = f"static/zh/{voice}.mp3"
|
|
|
750 |
tprint(f'🆗CLONE COMPLETE,{round(time2-time1,4)}s')
|
751 |
return output_wav
|
752 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
753 |
def text_to_speech(voice, text):
|
754 |
language = lang_detector(text)
|
755 |
+
if language == "English":
|
756 |
voice = f"static/en/{voice}.mp3"
|
757 |
else:
|
758 |
voice = f"static/zh/{voice}.mp3"
|