feat: Upload models, outputs and results
Add model folders with early instructions and a main.py file for testing. Add output folder for wav files generated. Add asset folder with manito.wav inside. Add env.example. Update readme.md for clear instructions to follow.
This commit is contained in:
@@ -0,0 +1 @@
|
||||
3.12
|
||||
@@ -0,0 +1,14 @@
|
||||
# Pocket-tts
|
||||
|
||||
## About
|
||||
This model is documented to have 100M parameters.
|
||||
This model of Pocket-tts calls huggingface as its a gated model, so you need access it and ask for permition to use it.
|
||||
This is the link. ```https://huggingface.co/kyutai/pocket-tts```
|
||||
|
||||
## Setup
|
||||
|
||||
```powershell
|
||||
uv sync
|
||||
.venv\Scripts\activate
|
||||
uv run python main.py
|
||||
```
|
||||
@@ -0,0 +1,61 @@
|
||||
import os
|
||||
import time
|
||||
|
||||
import numpy as np
|
||||
import soundfile as sf
|
||||
import sounddevice as sd
|
||||
from dotenv import load_dotenv
|
||||
from pocket_tts import TTSModel, export_model_state
|
||||
|
||||
|
||||
load_dotenv("../../.env")
|
||||
|
||||
archivo_voz = "../../assets/manito.wav"
|
||||
archivo_cache = "manito_es.safetensors"
|
||||
carpeta_salida = "../../outputs/pocket-tts"
|
||||
texto = "Hola, me llamo Manito y me encanta aprender contigo. ¿Jugamos un rato? Vamos a descubrir colores, formas y números juntos."
|
||||
|
||||
os.makedirs(carpeta_salida, exist_ok=True)
|
||||
|
||||
print("Cargando el modelo Pocket TTS...")
|
||||
tts = TTSModel.load_model(language="spanish", temp=1)
|
||||
sr = tts.sample_rate
|
||||
|
||||
try:
|
||||
voz = tts.get_state_for_audio_prompt(archivo_cache)
|
||||
except Exception:
|
||||
voz = tts.get_state_for_audio_prompt(archivo_voz)
|
||||
export_model_state(voz, archivo_cache)
|
||||
|
||||
t0 = time.perf_counter()
|
||||
previo = t0
|
||||
primero = None
|
||||
muestras = 0
|
||||
en_escritura = 0.0
|
||||
partes = []
|
||||
registro = []
|
||||
|
||||
with sd.OutputStream(samplerate=sr, channels=1, dtype="float32", latency="high") as salida:
|
||||
for chunk in tts.generate_audio_stream(voz, texto):
|
||||
llegada = time.perf_counter()
|
||||
if primero is None:
|
||||
primero = llegada - t0
|
||||
datos = chunk.detach().cpu().numpy().astype(np.float32).reshape(-1, 1)
|
||||
muestras += datos.size
|
||||
registro.append((datos.size, llegada - previo))
|
||||
partes.append(datos)
|
||||
t1 = time.perf_counter()
|
||||
salida.write(datos)
|
||||
previo = time.perf_counter()
|
||||
en_escritura += previo - t1
|
||||
fin = time.perf_counter()
|
||||
|
||||
total = fin - t0
|
||||
generacion = total - en_escritura
|
||||
duracion = muestras / sr
|
||||
|
||||
sf.write(f"{carpeta_salida}/pocket_tts.wav", np.concatenate(partes), sr)
|
||||
|
||||
print(f"primer fragmento: {primero:.2f}s | generación: {generacion:.2f}s | total con reproducción: {total:.2f}s | audio: {duracion:.2f}s | RTF: {generacion / duracion:.2f}")
|
||||
print(f"chunks: {len(chunks_total := registro)}")
|
||||
print("Listo.")
|
||||
Binary file not shown.
@@ -0,0 +1,12 @@
|
||||
[project]
|
||||
name = "pocket-tts-demo"
|
||||
version = "0.1.0"
|
||||
description = "Add your description here"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.12"
|
||||
dependencies = [
|
||||
"dotenv>=0.9.9",
|
||||
"pocket-tts>=4.0.1",
|
||||
"sounddevice>=0.5.6",
|
||||
"soundfile>=0.14.0",
|
||||
]
|
||||
Generated
+1589
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user