Pendrokar commited on
Commit
294478a
β€’
1 Parent(s): f7cbc18

Autoplay default voice sample

Browse files
Files changed (1) hide show
  1. app.py +13 -24
app.py CHANGED
@@ -8,17 +8,12 @@ import threading
8
  from huggingface_hub import hf_hub_download
9
  import gradio as gr
10
 
11
- # try:
12
  import resources.app.no_server as xvaserver
13
- # except:
14
- # print('server.log contents:')
15
- # with open('resources/app/server.log', 'r') as f:
16
- # print(f.read())
17
-
18
 
19
  hf_model_name = "Pendrokar/xvapitch_nvidia"
20
  hf_cache_models_path = '/home/user/.cache/huggingface/hub/models--Pendrokar--xvapitch_nvidia/snapshots/61b10e60b22bc21c1e072f72f1108b9c2b21e94c/'
21
- models_path = '/home/user/.cache/huggingface/hub/models--Pendrokar--xvapitch_nvidia/snapshots/61b10e60b22bc21c1e072f72f1108b9c2b21e94c/'
22
 
23
  # FIXME: currently hardcoded in DeepMoji code
24
  # try:
@@ -349,6 +344,9 @@ def reset_em_sliders(
349
  surprise
350
  )
351
 
 
 
 
352
  def toggle_deepmoji(
353
  checked,
354
  anger,
@@ -438,7 +436,7 @@ with gr.Blocks(css=".arpabet {display: inline-block; background-color: gray; bor
438
  with gr.Row(): # Main row for inputs and language selection
439
  with gr.Column(): # Input column
440
  output_wav = gr.Audio(
441
- label="22kHz audio output",
442
  type="filepath",
443
  editable=False,
444
  autoplay=True
@@ -562,21 +560,12 @@ with gr.Blocks(css=".arpabet {display: inline-block; background-color: gray; bor
562
  ]
563
  )
564
 
 
 
 
 
 
 
565
  if __name__ == "__main__":
566
- # Run the web server in a separate thread
567
-
568
- # print('Attempting to connect to local xVASynth server...')
569
- # try:
570
- # response = requests.get('http://0.0.0.0:8008')
571
- # response.raise_for_status() # If the response contains an HTTP error status code, raise an exception
572
- # except requests.exceptions.RequestException as err:
573
- # print('Failed to connect to xVASynth!')
574
- # web_server_thread = threading.Thread(target=run_xvaserver)
575
- # print('Starting xVAServer thread')
576
- # web_server_thread.start()
577
-
578
- print('running Gradio interface')
579
  demo.launch()
580
-
581
- # Wait for the web server thread to finish (shouldn't be reached in normal execution)
582
- # web_server_thread.join()
 
8
  from huggingface_hub import hf_hub_download
9
  import gradio as gr
10
 
11
+ # start xVASynth server (no HTTP)
12
  import resources.app.no_server as xvaserver
 
 
 
 
 
13
 
14
  hf_model_name = "Pendrokar/xvapitch_nvidia"
15
  hf_cache_models_path = '/home/user/.cache/huggingface/hub/models--Pendrokar--xvapitch_nvidia/snapshots/61b10e60b22bc21c1e072f72f1108b9c2b21e94c/'
16
+ models_path = hf_cache_models_path
17
 
18
  # FIXME: currently hardcoded in DeepMoji code
19
  # try:
 
344
  surprise
345
  )
346
 
347
+ def set_default_audio(voice_id):
348
+ return models_path + voice_id + '.wav'
349
+
350
  def toggle_deepmoji(
351
  checked,
352
  anger,
 
436
  with gr.Row(): # Main row for inputs and language selection
437
  with gr.Column(): # Input column
438
  output_wav = gr.Audio(
439
+ label="22kHz audio output (autoplay enabled)",
440
  type="filepath",
441
  editable=False,
442
  autoplay=True
 
560
  ]
561
  )
562
 
563
+ voice_radio.change(
564
+ set_default_audio,
565
+ inputs=voice_radio,
566
+ outputs=output_wav
567
+ )
568
+
569
  if __name__ == "__main__":
570
+ print('running custom Gradio interface')
 
 
 
 
 
 
 
 
 
 
 
 
571
  demo.launch()