Spaces:
Running
Running
File size: 1,705 Bytes
2aebcac cec247a 2aebcac 906a298 a42a1df 942948a 5fc9763 e18b42e 2865f90 2aebcac 0629797 b1afef8 0629797 8249b6c 2aebcac b1afef8 2aebcac b1afef8 2aebcac b1afef8 2aebcac b1afef8 2aebcac b1afef8 2aebcac 59f7f3a 5ab8330 2aebcac 17c4704 2aebcac 3d8a6f1 2aebcac |
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
import gradio as gr
import torch
import soundfile as sf
import spaces
import os
import numpy as np
import re
from transformers import SpeechT5Processor, SpeechT5ForTextToSpeech, SpeechT5HifiGan, AutoTokenizer
from speechbrain.pretrained import EncoderClassifier
from datasets import load_dataset
from huggingface_hub import hf_hub_download
import uuid
import wave
import io
import tempfile
import shutil
import importlib.util
from huggingface_hub import hf_hub_download
device = "cuda" if torch.cuda.is_available() else "cpu"
auth_token = os.environ.get("hf_token") or True
tts_path = hf_hub_download(repo_id="fahadqazi/private-code", filename="sindhi_tts_module.py", use_auth_token=auth_token)
spec = importlib.util.spec_from_file_location("sindhi_tts_module", tts_path)
tts_module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(tts_module)
SindhiTTSClass = tts_module.SindhiTTS
SindhiTTS = SindhiTTSClass(
auth_token=auth_token
)
iface = gr.Interface(
fn=SindhiTTS.synthesize,
inputs=[
gr.Textbox(label="Enter Sindhi text to convert to speech", value="سنڌي ماڻھو ڏَکڻ ايشيا ۾ آباد ماڻھن جو هڪ نسلي گروھ آهي جيڪو دراوڙ، آريائي ۽ سامي نسلن سان تعلق رکي ٿو۔", rtl=True),
gr.Radio(
choices=[("Female", 1), ("Male", 0)],
value=1,
label="Choose Gender"
)
],
outputs=[
gr.Audio(label="Generated Speech", type="numpy")
],
title="Sindhi Text-to-Speech Demo",
description="Enter Sindhi text, and listen to the generated speech. Use shorter messages for better results."
)
iface.launch(share=True) |