Spaces:
Sleeping
Sleeping
File size: 998 Bytes
4e35e69 929aad9 4e35e69 929aad9 4e35e69 929aad9 4e35e69 929aad9 4e35e69 929aad9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
from gradio_client import Client, file
import requests
import os
HF_TOKEN = os.getenv('HF_TOKEN')
client = Client("dskill/sd-audio", hf_token=HF_TOKEN, download_files=True)
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://dskill-sd-audio.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)
|