File size: 962 Bytes
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
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)