amirgame197 commited on
Commit
9417890
·
verified ·
1 Parent(s): e03a912

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -13,8 +13,6 @@ voice_id = borna_model[2]
13
  STATIC_DIR = "static"
14
  os.makedirs(STATIC_DIR, exist_ok=True)
15
 
16
-
17
-
18
  def tts(text):
19
  input_path = os.path.join(STATIC_DIR, "input.txt")
20
  with open(input_path, "w", encoding="utf-8") as f:
@@ -29,10 +27,11 @@ def tts(text):
29
  (sr, audio), _ = tts_interface(voice_id, text.strip(), '')
30
  temp_wav = os.path.join(STATIC_DIR, f"{uuid.uuid4().hex}.wav")
31
  sf.write(temp_wav, audio, samplerate=sr, subtype="PCM_16")
32
-
33
  out_path = temp_wav.replace(".wav", ".ogg")
34
  sound = AudioSegment.from_wav(temp_wav)
35
- sound.export(out_path, format="ogg")
 
36
 
37
  os.remove(temp_wav)
38
  return out_path
 
13
  STATIC_DIR = "static"
14
  os.makedirs(STATIC_DIR, exist_ok=True)
15
 
 
 
16
  def tts(text):
17
  input_path = os.path.join(STATIC_DIR, "input.txt")
18
  with open(input_path, "w", encoding="utf-8") as f:
 
27
  (sr, audio), _ = tts_interface(voice_id, text.strip(), '')
28
  temp_wav = os.path.join(STATIC_DIR, f"{uuid.uuid4().hex}.wav")
29
  sf.write(temp_wav, audio, samplerate=sr, subtype="PCM_16")
30
+
31
  out_path = temp_wav.replace(".wav", ".ogg")
32
  sound = AudioSegment.from_wav(temp_wav)
33
+ sound = sound.set_channels(1)
34
+ sound.export(out_path, format="ogg", codec="libopus")
35
 
36
  os.remove(temp_wav)
37
  return out_path