AI-trainer1 commited on
Commit
3cda040
·
verified ·
1 Parent(s): 22fdf85

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -4,9 +4,11 @@ import os
4
  import tempfile
5
  import sounddevice as sd
6
  from scipy.io.wavfile import write
 
7
 
8
  # Agree to Coqui's terms
9
  os.environ["COQUI_TOS_AGREED"] = "1"
 
10
 
11
  # Load the model and optimize CPU usage
12
  tts = TTS(model_name="tts_models/multilingual/multi-dataset/xtts_v2", gpu=False)
@@ -21,7 +23,6 @@ LANGUAGES = {
21
  "Italian": "it",
22
  "Hindi" : "hi",
23
  "Russian": "ru",
24
- "Spanish": "es",
25
  "Turkish": "tr",
26
  "Japanese": "ja",
27
  "Korean": "ko",
@@ -31,12 +32,12 @@ LANGUAGES = {
31
  # Function to generate voice
32
  def generate_voice(text, speaker_audio, language):
33
  output_path = tempfile.mktemp(suffix=".wav")
34
-
35
  tts.tts_to_file(
36
  text=text,
37
  speaker_wav=speaker_audio,
38
  file_path=output_path,
39
- language=LANGUAGES.get(language, "en")
 
40
  )
41
  return output_path
42
 
@@ -82,3 +83,5 @@ with gr.Blocks() as demo:
82
 
83
  # Launch the app
84
  demo.launch(server_name="0.0.0.0", server_port=7860, share=True)
 
 
 
4
  import tempfile
5
  import sounddevice as sd
6
  from scipy.io.wavfile import write
7
+ from concurrent.futures import ThreadPoolExecutor
8
 
9
  # Agree to Coqui's terms
10
  os.environ["COQUI_TOS_AGREED"] = "1"
11
+ os.environ["OMP_NUM_THREADS"] = "2" # Set CPU threads to 8 (adjust based on your CPU cores)
12
 
13
  # Load the model and optimize CPU usage
14
  tts = TTS(model_name="tts_models/multilingual/multi-dataset/xtts_v2", gpu=False)
 
23
  "Italian": "it",
24
  "Hindi" : "hi",
25
  "Russian": "ru",
 
26
  "Turkish": "tr",
27
  "Japanese": "ja",
28
  "Korean": "ko",
 
32
  # Function to generate voice
33
  def generate_voice(text, speaker_audio, language):
34
  output_path = tempfile.mktemp(suffix=".wav")
 
35
  tts.tts_to_file(
36
  text=text,
37
  speaker_wav=speaker_audio,
38
  file_path=output_path,
39
+ language=LANGUAGES.get(language, "en"),
40
+ sample_rate=44100,
41
  )
42
  return output_path
43
 
 
83
 
84
  # Launch the app
85
  demo.launch(server_name="0.0.0.0", server_port=7860, share=True)
86
+
87
+