File size: 763 Bytes
1453b79
 
 
93e94bb
1453b79
dc9102d
1453b79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dc9102d
1453b79
 
 
 
db2e732
1453b79
93e94bb
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
import requests
import base64
import soundfile as sf
import numpy as np

API_URL = "https://qg5sx5kndg4rp1gn.us-east-1.aws.endpoints.huggingface.cloud"
headers = {
	"Accept" : "application/json",
	"Authorization": "Bearer token",
	"Content-Type": "application/json" 
}

def query(payload):
	response = requests.post(API_URL, headers=headers, json=payload)
	return response.json()

response = query({
	"inputs": "deep bass hip hop with trumpet",
	"parameters": {}
})

audio_data = np.array(response["audio_data"], dtype=np.float32)
sampling_rate = response["sampling_rate"]

# Write the audio data to a WAV file
output_file_path = "output.wav"  # Specify the file path
sf.write(output_file_path, audio_data, sampling_rate)

print("Audio file saved successfully.")