Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -18,14 +18,7 @@ async def text_to_speech_edge(text, language_code):
|
|
18 |
|
19 |
await communicate.save(tmp_path)
|
20 |
|
21 |
-
# new_temp_path = tmp_path.replace(".mp3", ".wav")
|
22 |
-
# (
|
23 |
-
# ffmpeg.input(tmp_path)
|
24 |
-
# .output(new_temp_path)
|
25 |
-
# .run()
|
26 |
-
# )
|
27 |
return tmp_path
|
28 |
-
# return new_temp_path
|
29 |
|
30 |
def cleanup_temp_files(temp_dir, max_age_seconds=3600):
|
31 |
"""ๅฎๆๆธ
็่ถ
้ max_age_seconds ็่จๆๆไปถ"""
|
@@ -38,11 +31,11 @@ def cleanup_temp_files(temp_dir, max_age_seconds=3600):
|
|
38 |
if file_age > max_age_seconds:
|
39 |
os.remove(file_path)
|
40 |
print(f"ๅทฒๅช้ค้ๆ็่จๆๆไปถ: {file_path}")
|
41 |
-
time.sleep(
|
42 |
|
43 |
# ๅๅๆธ
็่จๆๆไปถ็็ท็จ
|
44 |
tempfile_tempdir = tempfile.gettempdir()
|
45 |
-
cleanup_thread = threading.Thread(target=cleanup_temp_files, args=(tempfile_tempdir,
|
46 |
cleanup_thread.start()
|
47 |
|
48 |
input_text = gr.Textbox(lines=5, label="่ผธๅ
ฅๆๆฌ")
|
|
|
18 |
|
19 |
await communicate.save(tmp_path)
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
return tmp_path
|
|
|
22 |
|
23 |
def cleanup_temp_files(temp_dir, max_age_seconds=3600):
|
24 |
"""ๅฎๆๆธ
็่ถ
้ max_age_seconds ็่จๆๆไปถ"""
|
|
|
31 |
if file_age > max_age_seconds:
|
32 |
os.remove(file_path)
|
33 |
print(f"ๅทฒๅช้ค้ๆ็่จๆๆไปถ: {file_path}")
|
34 |
+
time.sleep(600) # ๆฏ้10ๅ้ๆๅท่กไธๆฌกๆธ
็
|
35 |
|
36 |
# ๅๅๆธ
็่จๆๆไปถ็็ท็จ
|
37 |
tempfile_tempdir = tempfile.gettempdir()
|
38 |
+
cleanup_thread = threading.Thread(target=cleanup_temp_files, args=(tempfile_tempdir,3600), daemon=True)
|
39 |
cleanup_thread.start()
|
40 |
|
41 |
input_text = gr.Textbox(lines=5, label="่ผธๅ
ฅๆๆฌ")
|