poemsforaphrodite commited on
Commit
821e73d
1 Parent(s): bec1b9a

Update openvoice_app.py

Browse files
Files changed (1) hide show
  1. openvoice_app.py +12 -7
openvoice_app.py CHANGED
@@ -52,7 +52,7 @@ def delete_voice(api_key, voice_id):
52
 
53
  # Predict function with rate limiting based on IP address
54
  #@limiter.limit("100 per minute")
55
- def predict(prompt, style, audio_file_pth):
56
  text_hint = ''
57
  if len(prompt) < 2:
58
  text_hint += "[ERROR] Please provide a longer prompt text.\n"
@@ -63,7 +63,7 @@ def predict(prompt, style, audio_file_pth):
63
 
64
  print(audio_file_pth)
65
  voice = client.clone(
66
- name="TrialVoice",
67
  description="A trial voice model for testing",
68
  files=[audio_file_pth],
69
  )
@@ -73,16 +73,16 @@ def predict(prompt, style, audio_file_pth):
73
 
74
  save_path = f'{output_dir}/output.wav'
75
  data = get_voices(api_key)
76
- # Find all voice IDs with the name "TrialVoice"
77
- trial_voice_ids = [voice.get("voice_id") for voice in data['voices'] if voice.get("name") == "TrialVoice"]
78
 
79
- # # Delete each voice with the name "TrialVoice"
80
  # for voice_id in trial_voice_ids:
81
  # status_code, response_text = delete_voice(api_key, voice_id)
82
  # print(f"Deleted voice ID {voice_id}: Status Code {status_code}, Response {response_text}")
83
 
84
  # if not trial_voice_ids:
85
- # print("No voices with the name 'TrialVoice' found.")
86
 
87
  return text_hint, save_path, audio_file_pth
88
 
@@ -108,6 +108,11 @@ with gr.Blocks(gr.themes.Glass()) as demo:
108
  value="resources/demo_speaker2.mp3",
109
  sources=["upload"], # Allow only upload
110
  )
 
 
 
 
 
111
  tts_button = gr.Button("Send", elem_id="send-btn", visible=True)
112
 
113
  with gr.Column():
@@ -115,7 +120,7 @@ with gr.Blocks(gr.themes.Glass()) as demo:
115
  audio_gr = gr.Audio(label="Synthesised Audio", autoplay=True)
116
  ref_audio_gr = gr.Audio(label="Reference Audio Used")
117
 
118
- tts_button.click(predict, [input_text_gr, style_gr, ref_gr], outputs=[out_text_gr, audio_gr, ref_audio_gr])
119
 
120
  demo.queue()
121
  demo.launch(debug=True, show_api=False, share=args.share)
 
52
 
53
  # Predict function with rate limiting based on IP address
54
  #@limiter.limit("100 per minute")
55
+ def predict(prompt, style, audio_file_pth, voice_name):
56
  text_hint = ''
57
  if len(prompt) < 2:
58
  text_hint += "[ERROR] Please provide a longer prompt text.\n"
 
63
 
64
  print(audio_file_pth)
65
  voice = client.clone(
66
+ name=voice_name,
67
  description="A trial voice model for testing",
68
  files=[audio_file_pth],
69
  )
 
73
 
74
  save_path = f'{output_dir}/output.wav'
75
  data = get_voices(api_key)
76
+ # Find all voice IDs with the name provided by the user
77
+ trial_voice_ids = [voice.get("voice_id") for voice in data['voices'] if voice.get("name") == voice_name]
78
 
79
+ # # Delete each voice with the name provided by the user
80
  # for voice_id in trial_voice_ids:
81
  # status_code, response_text = delete_voice(api_key, voice_id)
82
  # print(f"Deleted voice ID {voice_id}: Status Code {status_code}, Response {response_text}")
83
 
84
  # if not trial_voice_ids:
85
+ # print("No voices with the name provided by the user found.")
86
 
87
  return text_hint, save_path, audio_file_pth
88
 
 
108
  value="resources/demo_speaker2.mp3",
109
  sources=["upload"], # Allow only upload
110
  )
111
+ voice_name_gr = gr.Textbox(
112
+ label="Voice Name",
113
+ info="Name for the cloned voice model.",
114
+ value="TrialVoice"
115
+ )
116
  tts_button = gr.Button("Send", elem_id="send-btn", visible=True)
117
 
118
  with gr.Column():
 
120
  audio_gr = gr.Audio(label="Synthesised Audio", autoplay=True)
121
  ref_audio_gr = gr.Audio(label="Reference Audio Used")
122
 
123
+ tts_button.click(predict, [input_text_gr, style_gr, ref_gr, voice_name_gr], outputs=[out_text_gr, audio_gr, ref_audio_gr])
124
 
125
  demo.queue()
126
  demo.launch(debug=True, show_api=False, share=args.share)