File size: 549 Bytes
e657366
93e94bb
 
 
e657366
 
 
 
 
335a399
e657366
 
 
 
 
db2e732
 
93e94bb
 
 
 
 
 
 
db2e732
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
from handler import EndpointHandler
import soundfile as sf
import numpy as np


# init handler
my_handler = EndpointHandler(path=".")

# prepare sample payload
payload = {"inputs": "Lowfi hiphop with deep bass"}

# test the handler
pred=my_handler(payload)


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

sampling_rate = pred["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.")