the-walking-fish commited on
Commit
34a24ae
ยท
verified ยท
1 Parent(s): 6fb1636

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -9
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(60) # ๆฏ้š”ไธ€ๅฐๆ™‚ๅŸท่กŒไธ€ๆฌกๆธ…็†
42
 
43
  # ๅ•Ÿๅ‹•ๆธ…็†่‡จๆ™‚ๆ–‡ไปถ็š„็ทš็จ‹
44
  tempfile_tempdir = tempfile.gettempdir()
45
- cleanup_thread = threading.Thread(target=cleanup_temp_files, args=(tempfile_tempdir,30), daemon=True)
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="่ผธๅ…ฅๆ–‡ๆœฌ")