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.

this is what i did :

from gradio_client import Client

client = Client("mrfakename/MeloTTS")
result = client.predict(
    text="sample text",
    speaker="EN-US",
    speed=1,
    language="EN",
    api_name="/synthesize"
)
data, samplerate = sf.read(result)
sd.play(data, samplerate)
sd.wait()  # Wait until the file is done playing

Sign up or log in to comment