Spaces:
Runtime error
Runtime error
Yoni
commited on
Commit
ยท
7bc996c
1
Parent(s):
d7d2e7a
no message
Browse files- README.md +6 -5
- app.py +48 -0
- requirements.txt +4 -0
README.md
CHANGED
|
@@ -1,12 +1,13 @@
|
|
| 1 |
---
|
| 2 |
title: Hebrew Chat
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version: 5.23.
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
|
|
|
| 10 |
---
|
| 11 |
|
| 12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
title: Hebrew Chat
|
| 3 |
+
emoji: ๐
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: red
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 5.23.1
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
+
short_description: AI agent in Hebrew for everyday conversations
|
| 11 |
---
|
| 12 |
|
| 13 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from faster_whisper import WhisperModel
|
| 4 |
+
from israwave import IsrawaveTTS
|
| 5 |
+
import tempfile
|
| 6 |
+
import os
|
| 7 |
+
import zipfile
|
| 8 |
+
from huggingface_hub import hf_hub_download
|
| 9 |
+
|
| 10 |
+
# Download model files from HF dataset (YoniAfek/israwaveTTS)
|
| 11 |
+
espeak_zip_path = hf_hub_download(repo_id="YoniAfek/israwaveTTS", filename="espeak-ng-data.zip")
|
| 12 |
+
israwave_path = hf_hub_download(repo_id="YoniAfek/israwaveTTS", filename="israwave.onnx")
|
| 13 |
+
nakdimon_path = hf_hub_download(repo_id="YoniAfek/israwaveTTS", filename="nakdimon.onnx")
|
| 14 |
+
|
| 15 |
+
# Extract espeak-ng-data
|
| 16 |
+
espeak_dir = os.path.join(tempfile.gettempdir(), "espeak-ng-data")
|
| 17 |
+
os.makedirs(espeak_dir, exist_ok=True)
|
| 18 |
+
with zipfile.ZipFile(espeak_zip_path, "r") as zip_ref:
|
| 19 |
+
zip_ref.extractall(espeak_dir)
|
| 20 |
+
|
| 21 |
+
# Load whisper
|
| 22 |
+
whisper_model = WhisperModel("ivrit-ai/whisper-large-v3-turbo-ct2")
|
| 23 |
+
|
| 24 |
+
# Load israwave TTS
|
| 25 |
+
tts = IsrawaveTTS(
|
| 26 |
+
model_path=israwave_path,
|
| 27 |
+
speaker_model_path=nakdimon_path,
|
| 28 |
+
espeak_data_path=espeak_dir
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
+
# Transcribe + speak
|
| 32 |
+
def process_audio(audio_path):
|
| 33 |
+
segments, _ = whisper_model.transcribe(audio_path, language="he")
|
| 34 |
+
text = " ".join([seg.text for seg in segments])
|
| 35 |
+
tts_path = tempfile.NamedTemporaryFile(delete=False, suffix=".wav").name
|
| 36 |
+
tts.tts_to_file(text, tts_path)
|
| 37 |
+
return text, tts_path
|
| 38 |
+
|
| 39 |
+
# Interface
|
| 40 |
+
demo = gr.Interface(
|
| 41 |
+
fn=process_audio,
|
| 42 |
+
inputs=gr.Audio(type="filepath", label="๐๏ธ ืืงืื ืืช ืขืฆืื"),
|
| 43 |
+
outputs=[gr.Text(label="ืชืืืื"), gr.Audio(label="ืืืจื ืืงืื ืขืืจื")],
|
| 44 |
+
title="ืชืืืื ืืืืืืจ ืขื Israwave",
|
| 45 |
+
description="ืืืขืจืืช ืืชืืืืช ืืช ืื ืฉื ืืืจ ืืืฉืืืขื ืืืชื ืืืจื ืืงืื ืขืืจื. ืืงืืฆืื ืืืจืืื ื-Hugging Face Datasets"
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
faster-whisper
|
| 3 |
+
israwave
|
| 4 |
+
huggingface_hub
|