File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change 1
1
import uvicorn
2
2
from fastapi import FastAPI , Request
3
+
3
4
# from fastapi.middleware.cors import CORSMiddleware
4
- from starlette .middleware .cors import CORSMiddleware
5
+ from starlette .middleware .cors import CORSMiddleware
5
6
from pprint import pprint
6
7
from melo .api import TTS
7
8
import string
13
14
14
15
app = FastAPI ()
15
16
16
- punc = ''' ;:@#$%^&*_ -~※○●□■△▲◇◆▽▼→←↑↓↔↕↗↘↙↖↙↗↘↖↔↕─│┌┐└┘├┤┬┴┼━┃┏┓┗'''
17
+ punc = """ ;:@#$%^&*-~※○●□■△▲◇◆▽▼→←↑↓↔↕↗↘↙↖↙↗↘↖↔↕─│┌┐└┘├┤┬┴┼━┃┏┓┗+"""
17
18
18
19
# allowed_origins = [
19
20
# "http://localhost.tiangolo.com",
24
25
# "https://localhost:44345",
25
26
# ]
26
27
27
- allowed_origins = ["*" ]
28
+ allowed_origins = ["*" ]
28
29
29
30
app .add_middleware (
30
31
CORSMiddleware ,
@@ -52,16 +53,18 @@ async def root():
52
53
@app .post ("/api/synthesize" )
53
54
async def apifunction_generate_tts (request : Request ):
54
55
_json = await request .json ()
55
- pprint (_json )
56
+ # pprint(_json)
56
57
text = _json ["text" ]
57
- print (text )
58
+ # print(text)
58
59
59
60
for c in text :
60
61
if c in punc :
61
62
text = text .replace (c , "" )
63
+
64
+ text = text .replace ("\n " , " " )
62
65
63
- text = text . replace ( ' \n ' , ' ' )
64
-
66
+ # print(text )
67
+
65
68
response_data = model .tts_to_base64 (text , speaker_ids ["KR" ], speed = speed )
66
69
return response_data
67
70
You can’t perform that action at this time.
0 commit comments