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.")