Initial
Browse files- README.md +1 -3
- handler.py +21 -0
- requirements.txt +9 -0
README.md
CHANGED
|
@@ -1,3 +1 @@
|
|
| 1 |
-
|
| 2 |
-
license: mit
|
| 3 |
-
---
|
|
|
|
| 1 |
+
Bark inference endpoint
|
|
|
|
|
|
handler.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from bark import generate_audio, preload_models
|
| 2 |
+
import torch
|
| 3 |
+
import numpy as np
|
| 4 |
+
import scipy
|
| 5 |
+
import io
|
| 6 |
+
|
| 7 |
+
preload_models()
|
| 8 |
+
|
| 9 |
+
def infer(inputs):
|
| 10 |
+
text = inputs.get("text", "")
|
| 11 |
+
if not text.strip():
|
| 12 |
+
return {"error": "No input text provided."}
|
| 13 |
+
|
| 14 |
+
audio_array = generate_audio(text, history_prompt="v2/ru_speaker_0")
|
| 15 |
+
|
| 16 |
+
# Сохраняем в wav-поток
|
| 17 |
+
byte_io = io.BytesIO()
|
| 18 |
+
scipy.io.wavfile.write(byte_io, rate=24000, data=audio_array)
|
| 19 |
+
byte_io.seek(0)
|
| 20 |
+
|
| 21 |
+
return {"audio": byte_io.read()}
|
requirements.txt
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
torch==2.5.1
|
| 2 |
+
torchaudio==2.5.1
|
| 3 |
+
torchvision==0.20.1
|
| 4 |
+
numpy
|
| 5 |
+
scipy
|
| 6 |
+
pydub
|
| 7 |
+
srt
|
| 8 |
+
certifi
|
| 9 |
+
git+https://github.com/suno-ai/bark.git
|