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 11import uvicorn
22from fastapi import FastAPI , Request
3+
34# from fastapi.middleware.cors import CORSMiddleware
4- from starlette .middleware .cors import CORSMiddleware
5+ from starlette .middleware .cors import CORSMiddleware
56from pprint import pprint
67from melo .api import TTS
78import string
1314
1415app = FastAPI ()
1516
16- punc = ''' ;:@#$%^&*_ -~※○●□■△▲◇◆▽▼→←↑↓↔↕↗↘↙↖↙↗↘↖↔↕─│┌┐└┘├┤┬┴┼━┃┏┓┗'''
17+ punc = """ ;:@#$%^&*-~※○●□■△▲◇◆▽▼→←↑↓↔↕↗↘↙↖↙↗↘↖↔↕─│┌┐└┘├┤┬┴┼━┃┏┓┗+"""
1718
1819# allowed_origins = [
1920# "http://localhost.tiangolo.com",
2425# "https://localhost:44345",
2526# ]
2627
27- allowed_origins = ["*" ]
28+ allowed_origins = ["*" ]
2829
2930app .add_middleware (
3031 CORSMiddleware ,
@@ -52,16 +53,18 @@ async def root():
5253@app .post ("/api/synthesize" )
5354async def apifunction_generate_tts (request : Request ):
5455 _json = await request .json ()
55- pprint (_json )
56+ # pprint(_json)
5657 text = _json ["text" ]
57- print (text )
58+ # print(text)
5859
5960 for c in text :
6061 if c in punc :
6162 text = text .replace (c , "" )
63+
64+ text = text .replace ("\n " , " " )
6265
63- text = text . replace ( ' \n ' , ' ' )
64-
66+ # print(text )
67+
6568 response_data = model .tts_to_base64 (text , speaker_ids ["KR" ], speed = speed )
6669 return response_data
6770
You can’t perform that action at this time.
0 commit comments