umertayyeb commited on
Commit
95b78a2
·
verified ·
1 Parent(s): 26a1bd3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -14
app.py CHANGED
@@ -1,19 +1,21 @@
1
  from gradio_client import Client, handle_file
2
  import os
3
- hf_token=os.getenv("your_huggingface_token")
 
 
 
 
4
  client = Client("ResembleAI/Chatterbox", hf_token)
5
 
6
- # client = Client("ResembleAI/Chatterbox")
7
- # result = client.predict(
8
- # text_input="Now let's make my mum's favourite. So three mars bars into the pan. Then we add the tuna and just stir for a bit, just let the chocolate and fish infuse. A sprinkle of olive oil and some tomato ketchup. Now smell that. Oh boy this is going to be incredible.",
9
- # audio_prompt_path_input=handle_file('https://github.com/gradio-app/gradio/raw/main/test/test_files/audio_sample.wav'),
10
- # exaggeration_input=0.5,
11
- # temperature_input=0.8,
12
- # seed_num_input=0,
13
- # cfgw_input=0.5,
14
- # api_name="/generate_tts_audio"
15
- # )
16
 
 
17
  try:
18
  result = client.predict(
19
  text_input=text_input,
@@ -24,8 +26,7 @@ try:
24
  cfgw_input=cfgw_input,
25
  api_name="/generate_tts_audio"
26
  )
 
27
  except Exception as e:
 
28
  print(f"An error occurred: {e}")
29
- return "Error generating audio"
30
-
31
- print(result)
 
1
  from gradio_client import Client, handle_file
2
  import os
3
+
4
+ # Get Hugging Face token from environment variable
5
+ hf_token = os.getenv("your_huggingface_token") # Make sure this is set in your environment
6
+
7
+ # Initialize the Gradio client with the token
8
  client = Client("ResembleAI/Chatterbox", hf_token)
9
 
10
+ # Example text input, audio prompt URL, and other parameters
11
+ text_input = "Now let's make my mum's favourite. So three mars bars into the pan. Then we add the tuna and just stir for a bit, just let the chocolate and fish infuse. A sprinkle of olive oil and some tomato ketchup. Now smell that. Oh boy this is going to be incredible."
12
+ audio_prompt_url = 'https://github.com/gradio-app/gradio/raw/main/test/test_files/audio_sample.wav'
13
+ exaggeration_input = 0.5
14
+ temperature_input = 0.8
15
+ seed_num_input = 0
16
+ cfgw_input = 0.5
 
 
 
17
 
18
+ # Use try-except to handle any errors that might occur during the prediction
19
  try:
20
  result = client.predict(
21
  text_input=text_input,
 
26
  cfgw_input=cfgw_input,
27
  api_name="/generate_tts_audio"
28
  )
29
+ print(result) # Print the result (filepath to generated audio)
30
  except Exception as e:
31
+ # Handle the error by printing the exception message
32
  print(f"An error occurred: {e}")