Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,19 +1,21 @@
|
|
1 |
from gradio_client import Client, handle_file
|
2 |
import os
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
client = Client("ResembleAI/Chatterbox", hf_token)
|
5 |
|
6 |
-
#
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
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}")
|
|
|
|
|
|