Spaces:
Sleeping
Sleeping
fix split
Browse files
env.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import os
|
2 |
|
3 |
limit_cj = int(os.environ.get("limit_cj", 120)) #character
|
4 |
-
limit_en = int(os.environ.get("limit_en", 60)) #words
|
|
|
|
1 |
import os
|
2 |
|
3 |
limit_cj = int(os.environ.get("limit_cj", 120)) #character
|
4 |
+
limit_en = int(os.environ.get("limit_en", 60)) #words
|
5 |
+
how_to_cut = str(os.environ.get("how_to_cut", "Split every 50 characters"))
|
main.py
CHANGED
@@ -28,7 +28,6 @@ async def tts(
|
|
28 |
voice: DefaultVoice = Form(None),
|
29 |
text: str = Form(..., description="转换文本")):
|
30 |
language = lang_detector(text)
|
31 |
-
texts = cut5(text)
|
32 |
if custom_voice_file is not None:
|
33 |
os.makedirs("static/tmp", exist_ok=True)
|
34 |
content = await file.read()
|
@@ -40,15 +39,12 @@ async def tts(
|
|
40 |
"Content-Disposition": "attachment; filename=result.wav",
|
41 |
"Content-Type": "audio/wav",
|
42 |
}
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
audio_content = audio_file.read()
|
50 |
-
yield audio_content
|
51 |
-
return StreamingResponse(generate(), media_type="audio/wav", headers=headers)
|
52 |
|
53 |
|
54 |
if __name__ == '__main__':
|
|
|
28 |
voice: DefaultVoice = Form(None),
|
29 |
text: str = Form(..., description="转换文本")):
|
30 |
language = lang_detector(text)
|
|
|
31 |
if custom_voice_file is not None:
|
32 |
os.makedirs("static/tmp", exist_ok=True)
|
33 |
content = await file.read()
|
|
|
39 |
"Content-Disposition": "attachment; filename=result.wav",
|
40 |
"Content-Type": "audio/wav",
|
41 |
}
|
42 |
+
wav_path = clone_voice(
|
43 |
+
user_voice=voice, user_text=text, user_lang=language)
|
44 |
+
|
45 |
+
with open(wav_path, "rb") as audio_file:
|
46 |
+
audio_content = audio_file.read()
|
47 |
+
return Response(audio_content, headers=headers)
|
|
|
|
|
|
|
48 |
|
49 |
|
50 |
if __name__ == '__main__':
|
model.py
CHANGED
@@ -735,7 +735,7 @@ def clone_voice(user_voice,user_text,user_lang):
|
|
735 |
prompt_language,
|
736 |
user_text,
|
737 |
user_lang,
|
738 |
-
how_to_cut=
|
739 |
volume_scale=1.0)
|
740 |
time2=timer()
|
741 |
tprint(f'🆗CLONE COMPLETE,{round(time2-time1,4)}s')
|
|
|
735 |
prompt_language,
|
736 |
user_text,
|
737 |
user_lang,
|
738 |
+
how_to_cut=how_to_cut,
|
739 |
volume_scale=1.0)
|
740 |
time2=timer()
|
741 |
tprint(f'🆗CLONE COMPLETE,{round(time2-time1,4)}s')
|