Spaces:
Sleeping
Sleeping
from gradio_client import Client | |
import requests | |
import os | |
client = Client("artificialguybr/Stable-Audio-Open-Zero") | |
result = client.predict( | |
prompt="Ambient rainfall", | |
seconds_total=5, | |
steps=100, | |
cfg_scale=7, | |
api_name="/predict" | |
) | |
print(result) | |
# Split the path into parts | |
parts = result.split(os.sep) | |
# Extract the last two sections | |
last_two_sections = os.sep.join(parts[-2:]) | |
print(last_two_sections) | |
url_root = 'https://artificialguybr-stable-audio-open-zero.hf.space/file=/tmp/gradio/' | |
url = url_root + last_two_sections | |
# Send a GET request to the URL | |
response = requests.get(url) | |
# Check if the request was successful | |
if response.status_code == 200: | |
# Open a file in write-binary mode and write the content of the response to it | |
with open('output.wav', 'wb') as file: | |
file.write(response.content) | |
print('File downloaded successfully!') | |
else: | |
print('Failed to download the file. Status code:', response.status_code) | |