AngeT10 commited on
Commit
3a4982a
·
verified ·
1 Parent(s): 5042274

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -16
app.py CHANGED
@@ -5,7 +5,6 @@ import torch
5
  import zipfile
6
  from TTS.api import TTS
7
  from pydub import AudioSegment
8
- import mecab
9
 
10
  os.environ["COQUI_TOS_AGREED"] = "1"
11
 
@@ -48,15 +47,8 @@ def convert_to_wav(input_audio_file):
48
  return "temp.wav"
49
  return input_audio_file
50
 
51
- def preprocess_text(txt, katsu):
52
- if katsu:
53
- tagger = mecab.Tagger()
54
- txt = tagger.parse(txt).strip()
55
- return txt
56
-
57
  def synthesize_text(text, input_audio_file, language):
58
  input_audio_file = convert_to_wav(input_audio_file)
59
- text = preprocess_text(text, language == "ja")
60
  tts.tts_to_file(text=text, speaker_wav=input_audio_file, language=language, file_path="./output.wav")
61
  return "./output.wav"
62
 
@@ -81,16 +73,15 @@ def clone(text, input_file, language, url=None, use_url=False):
81
  input_audio_file = input_file.name
82
 
83
  output_file_path = synthesize_text(text, input_audio_file, language)
84
- returnoutput_file_path
85
 
86
  iface = gr.Interface(
87
  fn=clone,
88
- inputs=["text", gr.File(label="Input File", file_types=[".zip", ".wav", ".mp3", ".flac", ".mp4"]), "language", "url", gr.Checkbox(label="Use URL")],
89
- outputs="text",
90
- title="Voice Cloning Application",
91
- description="Enter text, select an audio file, choose a language, and optionally input a URL to clone a voice.",
92
- theme="default",
93
- allow_flagging="never"
94
  )
95
 
96
- iface.launch()
 
5
  import zipfile
6
  from TTS.api import TTS
7
  from pydub import AudioSegment
 
8
 
9
  os.environ["COQUI_TOS_AGREED"] = "1"
10
 
 
47
  return "temp.wav"
48
  return input_audio_file
49
 
 
 
 
 
 
 
50
  def synthesize_text(text, input_audio_file, language):
51
  input_audio_file = convert_to_wav(input_audio_file)
 
52
  tts.tts_to_file(text=text, speaker_wav=input_audio_file, language=language, file_path="./output.wav")
53
  return "./output.wav"
54
 
 
73
  input_audio_file = input_file.name
74
 
75
  output_file_path = synthesize_text(text, input_audio_file, language)
76
+ return output_file_path
77
 
78
  iface = gr.Interface(
79
  fn=clone,
80
+ inputs=["text", gr.File(label="Input File", file_types=[".zip", *AUDIO_FORMATS]), gr.Dropdown(choices=LANGUAGES, label="Language"), gr.Text(label="URL"), gr.Checkbox(label="Use URL", value=False)],
81
+ outputs=gr.Audio(type='filepath'),
82
+ title='Voice Clone',
83
+ description=""" by [Angetyde](https://youtube.com/@Angetyde?si=7nusP31nTumIkPTF) and [Tony Assi](https://www.tonyassi.com/ ) use this colab with caution <3. """,
84
+ theme=gr.themes.Base(primary_hue="teal", secondary_hue="teal", neutral_hue="slate")
 
85
  )
86
 
87
+ iface.launch(share=True)