Amamrnaf commited on
Commit
0d6259a
·
1 Parent(s): e134535

final update

Browse files
Files changed (2) hide show
  1. app.py +3 -3
  2. metaVoice.py +22 -22
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import gradio as gr
2
  import os
3
  from coqui_tts import run_audio_generation_v1
4
- # from metaVoice import run_audio_generation_v2
5
  import shutil
6
 
7
 
@@ -29,8 +29,8 @@ def process_audio(input_text, speaker_audio, speaker_name, option_selected):
29
  # Generate TTS audio using run_audio_generation_v1
30
  run_audio_generation_v1(input_text)
31
  elif option_selected =="metaVoice":
32
- return f"The option is {option_selected }not implemented yet."
33
- # run_audio_generation_v2(input_text)
34
  else:
35
  return f"The option is not implemented yet."
36
 
 
1
  import gradio as gr
2
  import os
3
  from coqui_tts import run_audio_generation_v1
4
+ from metaVoice import run_audio_generation_v2
5
  import shutil
6
 
7
 
 
29
  # Generate TTS audio using run_audio_generation_v1
30
  run_audio_generation_v1(input_text)
31
  elif option_selected =="metaVoice":
32
+ # return f"The option is {option_selected }not implemented yet."
33
+ run_audio_generation_v2(input_text)
34
  else:
35
  return f"The option is not implemented yet."
36
 
metaVoice.py CHANGED
@@ -1,30 +1,30 @@
1
- # from fam.llm.fast_inference import TTS
2
- # import string
3
- # import soundfile as sf
4
 
5
- # def remove_punctuation(sentence):
6
- # translator = str.maketrans('', '', string.punctuation)
7
- # sentence = sentence.translate(translator)
8
 
9
- # # Remove line breaks
10
- # sentence = sentence.replace('\n', ' ').replace('\r', '')
11
 
12
- # return sentence
13
 
14
- # def run_audio_generation_v2(new_text,accent='None'):
15
- # tts = TTS()
16
- # new_text = new_text.replace('\n', ' ').replace('\r', '')
17
- # new_text_mod = remove_punctuation(new_text)
18
 
19
- # new_text_split = new_text_mod.split()
20
- # for word in new_text_split:
21
- # if len(word)>=2 and word.isupper():
22
- # new_text = new_text.replace(word, " ".join([*word]))
23
 
24
- # wav_file = tts.synthesise(
25
- # text=new_text,
26
- # spk_ref_path="./tmp/audio/speaker_wav.wav" # you can use any speaker reference file (WAV, OGG, MP3, FLAC, etc.)
27
- # )
28
- # sf.write('audio/output.wav', wav_file, samplerate=22050)
29
 
30
 
 
1
+ from fam.llm.fast_inference import TTS
2
+ import string
3
+ import soundfile as sf
4
 
5
+ def remove_punctuation(sentence):
6
+ translator = str.maketrans('', '', string.punctuation)
7
+ sentence = sentence.translate(translator)
8
 
9
+ # Remove line breaks
10
+ sentence = sentence.replace('\n', ' ').replace('\r', '')
11
 
12
+ return sentence
13
 
14
+ def run_audio_generation_v2(new_text,accent='None'):
15
+ tts = TTS()
16
+ new_text = new_text.replace('\n', ' ').replace('\r', '')
17
+ new_text_mod = remove_punctuation(new_text)
18
 
19
+ new_text_split = new_text_mod.split()
20
+ for word in new_text_split:
21
+ if len(word)>=2 and word.isupper():
22
+ new_text = new_text.replace(word, " ".join([*word]))
23
 
24
+ wav_file = tts.synthesise(
25
+ text=new_text,
26
+ spk_ref_path="./tmp/audio/speaker_wav.wav" # you can use any speaker reference file (WAV, OGG, MP3, FLAC, etc.)
27
+ )
28
+ sf.write('audio/output.wav', wav_file, samplerate=22050)
29
 
30