File size: 737 Bytes
839665a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
27
28
29
30
import gradio as gr
import onnxruntime as ort
import numpy as np
import soundfile as sf

# Load ONNX model
session = ort.InferenceSession("assets/model.onnx", providers=["CPUExecutionProvider"])

def tts(text):
    # Encode text to IDs (dummy simple encoding: byte values)
    input_ids = np.array([list(text.encode("utf-8"))], dtype=np.int64)

    # Run ONNX model
    audio = session.run(None, {"text": input_ids})[0][0]

    # Normalize audio if needed
    audio = audio.astype(np.float32)
    return (44100, audio)

def infer(text):
    return tts(text)

iface = gr.Interface(
    fn=infer,
    inputs=gr.Textbox(label="Input text"),
    outputs=gr.Audio(label="Output audio"),
    title="Supertonic TTS (CPU mode)"
)

iface.launch()