Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -26,8 +26,6 @@ for name in list_repo_files(repo_id="balacoon/tts"):
|
|
26 |
local_dir=os.getcwd(),
|
27 |
)
|
28 |
|
29 |
-
tts = TTS(os.path.join(os.getcwd(), tts_model_str))
|
30 |
-
|
31 |
# locker that disallow access to the tts object from more then one thread
|
32 |
locker = Lock()
|
33 |
|
@@ -101,6 +99,9 @@ async def greet(product,description):
|
|
101 |
if response.choices[0].message.content != "not moderated":
|
102 |
a_list = ["Sorry, I can't proceed for generating marketing email. Your content needs to be moderated first. Thank you!"]
|
103 |
with locker:
|
|
|
|
|
|
|
104 |
samples = tts.synthesize(a_list[0], "92")
|
105 |
yield (tts.get_sampling_rate(), samples)
|
106 |
else:
|
@@ -121,6 +122,9 @@ async def greet(product,description):
|
|
121 |
delta = chunk['choices'][0]['delta']
|
122 |
if 'content' in delta:
|
123 |
with locker:
|
|
|
|
|
|
|
124 |
samples = tts.synthesize(delta.get('content', ''), "92")
|
125 |
yield (tts.get_sampling_rate(), samples)
|
126 |
|
|
|
26 |
local_dir=os.getcwd(),
|
27 |
)
|
28 |
|
|
|
|
|
29 |
# locker that disallow access to the tts object from more then one thread
|
30 |
locker = Lock()
|
31 |
|
|
|
99 |
if response.choices[0].message.content != "not moderated":
|
100 |
a_list = ["Sorry, I can't proceed for generating marketing email. Your content needs to be moderated first. Thank you!"]
|
101 |
with locker:
|
102 |
+
if tts is not None:
|
103 |
+
del tts
|
104 |
+
tts = TTS(os.path.join(os.getcwd(), tts_model_str))
|
105 |
samples = tts.synthesize(a_list[0], "92")
|
106 |
yield (tts.get_sampling_rate(), samples)
|
107 |
else:
|
|
|
122 |
delta = chunk['choices'][0]['delta']
|
123 |
if 'content' in delta:
|
124 |
with locker:
|
125 |
+
if tts is not None:
|
126 |
+
del tts
|
127 |
+
tts = TTS(os.path.join(os.getcwd(), tts_model_str))
|
128 |
samples = tts.synthesize(delta.get('content', ''), "92")
|
129 |
yield (tts.get_sampling_rate(), samples)
|
130 |
|