doevent commited on
Commit
752aa18
·
1 Parent(s): c9cba23

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -56
app.py CHANGED
@@ -4,65 +4,18 @@ import os
4
  from TTS.api import TTS
5
  import time
6
 
7
- tts = TTS(model_name="voice_conversion_models/multilingual/vctk/freevc24", progress_bar=False, gpu=False)
8
  logging.basicConfig(level=logging.INFO)
9
- count = 0
10
-
11
- def main():
12
- global count
13
- count += 1
14
- if count > 50:
15
- time.sleep(5)
16
- os.system("rm -R /tmp/*")
17
- count = 0
18
-
19
- with gr.Blocks() as demo:
20
-
21
- with gr.Row():
22
- with gr.Column(variant="panel"):
23
- src_audio_mic = gr.Audio(source="microphone", label="Record your voice")
24
- src_audio_file = gr.Audio(
25
- source="upload", type="filepath", label="Or upload audio to convert"
26
- )
27
 
28
- with gr.Column(variant="panel"):
29
- tgt_audio_file = gr.Audio(
30
- source="upload", type="filepath", label="Select audio with target voice"
31
- )
32
-
33
- with gr.Row():
34
- convert_btn = gr.Button("Convert")
35
- with gr.Row():
36
- result_audio = gr.Audio()
37
-
38
-
39
- def voice_conversion(src_from_mic_, src_from_file_, tgt_from_file_):
40
- """
41
- helper function which checks where source come from
42
- """
43
- src_ = None
44
- if src_from_mic_:
45
- src_ = src_from_mic_
46
- elif src_from_file_:
47
- src_ = src_from_file_
48
- tgt_ = tgt_from_file_
49
- if not src_ or not tgt_:
50
- logging.warning("source or target are not provided")
51
- return
52
 
53
- print(src_)
54
- print(tgt_)
55
- tts.voice_conversion_to_file(source_wav=src_, target_wav=tgt_, file_path="output.wav")
56
- return "output.wav"
57
-
58
- convert_btn.click(
59
- voice_conversion,
60
- inputs=[src_audio_mic, src_audio_file, tgt_audio_file],
61
- outputs=result_audio,
62
- )
63
 
64
- demo.queue(concurrency_count=1).launch(show_api=False, show_error=True)
 
 
65
 
 
66
 
67
- if __name__ == "__main__":
68
- main()
 
4
  from TTS.api import TTS
5
  import time
6
 
 
7
  logging.basicConfig(level=logging.INFO)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
+ # TTS with on the fly voice conversion
10
+ api = TTS("tts_models/deu/fairseq/vits")
11
+ count = 0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
+ def audio_tts(txt, audio_file):
14
+ return {'cat': 0.3, 'dog': 0.7}
 
 
 
 
 
 
 
 
15
 
16
+ demo = gr.Interface(fn=image_classifier, inputs=[gr.Textbox(label="Input text TTS", value="Привет! Я Макс."),
17
+ gr.Audio(source="upload", type="filepath", label="Input audio")],
18
+ outputs=gr.Audio(source="upload", type="filepath", label="Output audio"))
19
 
20
+ demo.queue(concurrency_count=1).launch(show_error=True)
21