Hilley commited on
Commit
c140265
1 Parent(s): 29cc6e6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -11
app.py CHANGED
@@ -9,8 +9,8 @@ import numpy as np
9
 
10
  import ChatTTS
11
 
12
- import se_extractor
13
- from api import ToneColorConverter
14
  import soundfile
15
 
16
  print("loading ChatTTS model...")
@@ -80,7 +80,7 @@ tone_color_converter.load_ckpt(f'{ckpt_converter_en}/checkpoint.pth')
80
  def generate_audio(text, audio_ref, temperature, top_P, top_K, audio_seed_input, text_seed_input, refine_text_flag, refine_text_input):
81
  save_path = "output.wav"
82
 
83
- if audio_ref is not None:
84
  # Run the base speaker tts
85
  src_path = "tmp.wav"
86
  text_data = chat_tts(text, temperature, top_P, top_K, audio_seed_input, text_seed_input, refine_text_flag, refine_text_input, src_path)
@@ -108,17 +108,19 @@ def generate_audio(text, audio_ref, temperature, top_P, top_K, audio_seed_input,
108
 
109
 
110
  with gr.Blocks() as demo:
111
- gr.Markdown("# Enjoy chatting with your ai friends on website, telegram and so on! (https://linkin.love)")
 
 
112
 
113
  default_text = "Today a man knocked on my door and asked for a small donation toward the local swimming pool. I gave him a glass of water."
114
  text_input = gr.Textbox(label="Input Text", lines=4, placeholder="Please Input Text...", value=default_text)
115
 
116
 
117
  default_refine_text = "[oral_2][laugh_0][break_6]"
118
- refine_text_checkbox = gr.Checkbox(label="Refine text'oral' means add filler words, 'laugh' means add laughter, and 'break' means add a pause. (0-10) ", value=True)
119
  refine_text_input = gr.Textbox(label="Refine Prompt", lines=1, placeholder="Please Refine Prompt...", value=default_refine_text)
120
  with gr.Column():
121
- voice_ref = gr.Audio(label="请上传您喜欢的语音文件", type="filepath", value="")
122
 
123
  with gr.Row():
124
  temperature_slider = gr.Slider(minimum=0.00001, maximum=1.0, step=0.00001, value=0.3, label="Audio temperature")
@@ -148,15 +150,12 @@ with gr.Blocks() as demo:
148
  inputs=[text_input, voice_ref, temperature_slider, top_p_slider, top_k_slider, audio_seed_input, text_seed_input, refine_text_checkbox, refine_text_input],
149
  outputs=[audio_output,text_output])
150
 
151
- parser = argparse.ArgumentParser(description='ChatTTS demo Launch')
152
  parser.add_argument('--server_name', type=str, default='0.0.0.0', help='Server name')
153
  parser.add_argument('--server_port', type=int, default=8080, help='Server port')
154
  args = parser.parse_args()
155
 
156
- # demo.launch(server_name=args.server_name, server_port=args.server_port, inbrowser=True)
157
-
158
-
159
-
160
 
161
  if __name__ == '__main__':
162
  demo.launch()
 
9
 
10
  import ChatTTS
11
 
12
+ import OpenVoice.se_extractor as se_extractor
13
+ from OpenVoice.api import ToneColorConverter
14
  import soundfile
15
 
16
  print("loading ChatTTS model...")
 
80
  def generate_audio(text, audio_ref, temperature, top_P, top_K, audio_seed_input, text_seed_input, refine_text_flag, refine_text_input):
81
  save_path = "output.wav"
82
 
83
+ if audio_ref != "" :
84
  # Run the base speaker tts
85
  src_path = "tmp.wav"
86
  text_data = chat_tts(text, temperature, top_P, top_K, audio_seed_input, text_seed_input, refine_text_flag, refine_text_input, src_path)
 
108
 
109
 
110
  with gr.Blocks() as demo:
111
+ gr.Markdown("# <center>🥳 ChatTTS x OpenVoice 🥳</center>")
112
+ gr.Markdown("## <center>🌟 Make it sound super natural and switch it up to any voice you want, nailing the mood and tone also!🌟 </center>")
113
+ gr.Markdown("### <center>💕 Slide on over to [linkin.love](https://linkin.love) for a chat-fest with your AI buds!💕</center>")
114
 
115
  default_text = "Today a man knocked on my door and asked for a small donation toward the local swimming pool. I gave him a glass of water."
116
  text_input = gr.Textbox(label="Input Text", lines=4, placeholder="Please Input Text...", value=default_text)
117
 
118
 
119
  default_refine_text = "[oral_2][laugh_0][break_6]"
120
+ refine_text_checkbox = gr.Checkbox(label="Refine text", info="'oral' means add filler words, 'laugh' means add laughter, and 'break' means add a pause. (0-10) ", value=True)
121
  refine_text_input = gr.Textbox(label="Refine Prompt", lines=1, placeholder="Please Refine Prompt...", value=default_refine_text)
122
  with gr.Column():
123
+ voice_ref = gr.Audio(label="Reference Audio", info="Click on the ✎ button to upload your own target speaker audio", type="filepath", value="examples/speaker.mp3")
124
 
125
  with gr.Row():
126
  temperature_slider = gr.Slider(minimum=0.00001, maximum=1.0, step=0.00001, value=0.3, label="Audio temperature")
 
150
  inputs=[text_input, voice_ref, temperature_slider, top_p_slider, top_k_slider, audio_seed_input, text_seed_input, refine_text_checkbox, refine_text_input],
151
  outputs=[audio_output,text_output])
152
 
153
+ parser = argparse.ArgumentParser(description='ChatTTS-OpenVoice Launch')
154
  parser.add_argument('--server_name', type=str, default='0.0.0.0', help='Server name')
155
  parser.add_argument('--server_port', type=int, default=8080, help='Server port')
156
  args = parser.parse_args()
157
 
158
+ # demo.launch(server_name=args.server_name, server_port=args.server_port, inbrowser=True)
 
 
 
159
 
160
  if __name__ == '__main__':
161
  demo.launch()