File size: 694 Bytes
df4d1dd
7ba8e71
043490a
df4d1dd
7ba8e71
 
df4d1dd
 
 
7ba8e71
 
df4d1dd
7ba8e71
 
043490a
df4d1dd
7ba8e71
df4d1dd
7ba8e71
 
df4d1dd
7ba8e71
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
import base64
from Zonos_main.tts import ZonosTTS

# Initialize model ONCE when space starts
tts = ZonosTTS()  # <-- MUST WORK WITHOUT ERRORS

def generate_audio(text):
    try:
        # Generate raw audio bytes (MODIFY THIS TO MATCH YOUR MODEL)
        audio_bytes = tts.generate(text)  # Should return bytes directly
        
        # Convert to base64
        return f"data:audio/wav;base64,{base64.b64encode(audio_bytes).decode('utf-8')}"
        
    except Exception as e:
        raise gr.Error(f"TTS Failed: {str(e)}")

# Minimal interface
gr.Interface(
    fn=generate_audio,
    inputs=gr.Textbox(label="Input"),
    outputs=gr.Audio(type="filepath"),
).launch()