Initial clean deploy of Kokoro voice pipeline serverless containerr
Browse files- app,py +44 -0
- requirements.txt +4 -0
app,py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import outetts
|
| 3 |
+
import soundfile as sf
|
| 4 |
+
import tempfile
|
| 5 |
+
import os
|
| 6 |
+
|
| 7 |
+
# Initialize the OuteTTS pipeline (uses 0.1-350M by default)
|
| 8 |
+
model_config = outetts.HFModelConfig_v1(
|
| 9 |
+
model_path="OuteAI/OuteTTS-0.1-350M",
|
| 10 |
+
language="en",
|
| 11 |
+
)
|
| 12 |
+
interface = outetts.InterfaceHF(model_config)
|
| 13 |
+
|
| 14 |
+
def generate_speech(text: str, speed: float, temperature: float):
|
| 15 |
+
# Setup generation configuration
|
| 16 |
+
gen_config = outetts.GenerationConfig(
|
| 17 |
+
text=text,
|
| 18 |
+
temperature=temperature,
|
| 19 |
+
speed=speed
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
# Generate the audio array
|
| 23 |
+
output = interface.generate(gen_config)
|
| 24 |
+
|
| 25 |
+
# Save the output buffer array to a temporary WAV file
|
| 26 |
+
temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=".wav")
|
| 27 |
+
sf.write(temp_file.name, output.audio, output.sr)
|
| 28 |
+
|
| 29 |
+
return temp_file.name
|
| 30 |
+
|
| 31 |
+
# Create Gradio interface for both UI and API usage
|
| 32 |
+
demo = gr.Interface(
|
| 33 |
+
fn=generate_speech,
|
| 34 |
+
inputs=[
|
| 35 |
+
gr.Textbox(label="Text to Speech", value="Hello, welcome to OuteTTS speech api."),
|
| 36 |
+
gr.Slider(minimum=0.5, maximum=2.0, value=1.0, step=0.1, label="Speed"),
|
| 37 |
+
gr.Slider(minimum=0.1, maximum=1.0, value=0.1, step=0.05, label="Temperature")
|
| 38 |
+
],
|
| 39 |
+
outputs=gr.Audio(label="Generated Audio", type="filepath"),
|
| 40 |
+
title="OuteTTS API Endpoint"
|
| 41 |
+
)
|
| 42 |
+
|
| 43 |
+
if __name__ == "__main__":
|
| 44 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
outetts==0.2.3
|
| 2 |
+
gradio==4.40.0
|
| 3 |
+
soundfile
|
| 4 |
+
numpy
|