interferenc API

#1
by Joyko213456789 - opened

hello, how do i use the interference api for this model ?

import requests
import os

API_URL_TTS = "https://api-inference.huggingface.co/models/myshell-ai/MeloTTS-English"
headers = {"Authorization": ""}

def query_tts(payload):
response = requests.post(API_URL_TTS, headers=headers, json=payload)
return response.content

Perform the TTS query

audio_bytes = query_tts({
"inputs": "The answer to the universe is 42",
"language": "EN",
"options": {
"wait_for_model": True
}
})

Save the audio output to a file

output_file = "output_audio.wav"
with open(output_file, "wb") as f:
f.write(audio_bytes)

print(f"Audio has been saved to {output_file}")

from IPython.display import Audio, display
import IPython
IPython.display.Audio(audio_bytes)

this is my code but the returned audio is unplayable.

Sign up or log in to comment