barghavani commited on
Commit
6cfe2cc
·
1 Parent(s): 9116165

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -83
app.py DELETED
@@ -1,83 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """app
3
-
4
- Automatically generated by Colaboratory.
5
-
6
- Original file is located at
7
- https://colab.research.google.com/drive/1Ri9kvaz9F7Te2-5HZNUzHm-O6vgoSzhc
8
- """
9
-
10
- import os
11
- import tempfile
12
- import gradio as gr
13
- from TTS.utils.synthesizer import Synthesizer
14
- from huggingface_hub import hf_hub_download
15
-
16
- # Define constants
17
- modelInfo=[["vits-male-azure","best_model_15934.pth","config.json","saillab/persian-tts-azure-grapheme-60K/resolve/main/"],
18
- ["common_voice_reduce","checkpoint_26000.pth","config.json","https://huggingface.co/saillab/persian-tts-cv15-reduct-grapheme-multispeaker/resolve/main/"],
19
- ["vits_arman_ebook","best_model_66651.pth","config.json","https://huggingface.co/saillab/persian-tts-grapheme-arm24-finetuned-on1/resolve/main/"]
20
- # # Extract model names from MODEL_INFO
21
- # MODEL_NAMES = [info[0] for info in MODEL_INFO]
22
- ]
23
- MODEL_NAMES=[
24
- "vits male azure(best)",
25
- "common voice reduce",
26
- "vits arman ebook",
27
- #"persian-tts-grapheme-arm24-finetuned-on1",
28
- #"glowtts-male",
29
- #"glowtts-female",
30
- #"female tacotron2"
31
- ]
32
-
33
- MAX_TXT_LEN = 400
34
- TOKEN = os.getenv('HUGGING_FACE_HUB_TOKEN')
35
-
36
- # # Download models
37
- # for model_name, model_file, config_file, repo_name in MODEL_INFO:
38
- # os.makedirs(model_name, exist_ok=True)
39
- # print(f"|> Downloading: {model_name}")
40
-
41
- # # Use hf_hub_download to download models from private Hugging Face repositories
42
- # hf_hub_download(repo_id=repo_name, filename=model_file, use_auth_token=TOKEN)
43
- # hf_hub_download(repo_id=repo_name, filename=config_file, use_auth_token=TOKEN)
44
-
45
- repo_name = "saillab/persian-tts-azure-grapheme-60K"
46
- filename = "checkpoint_61800.pth"
47
-
48
- model_file = hf_hub_download(repo_name, filename, use_auth_token=TOKEN)
49
- config_file = hf_hub_download(repo_name, "config.json", use_auth_token=TOKEN)
50
-
51
-
52
- def synthesize(text: str, model_name: str) -> str:
53
- """Synthesize speech using the selected model."""
54
- if len(text) > MAX_TXT_LEN:
55
- text = text[:MAX_TXT_LEN]
56
- print(f"Input text was cut off as it exceeded the {MAX_TXT_LEN} character limit.")
57
-
58
- synthesizer = Synthesizer(model_file, config_file)
59
- if synthesizer is None:
60
- raise NameError("Model not found")
61
-
62
- wavs = synthesizer.tts(text)
63
-
64
- with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
65
- synthesizer.save_wav(wavs, fp)
66
- return fp.name
67
-
68
-
69
- iface = gr.Interface(
70
- fn=synthesize,
71
- inputs=[
72
- gr.Textbox(label="Enter Text to Synthesize:", value="زین همرهان سست عناصر، دلم گرفت."),
73
- gr.Radio(label="Pick a Model", choices=MODEL_NAMES, value=MODEL_NAMES[0]),
74
- ],
75
- outputs=gr.Audio(label="Output", type='filepath'),
76
- examples=[["زین همرهان سست عناصر، دلم گرفت.", MODEL_NAMES[0]]],
77
- title='Persian TTS Playground',
78
- description="Persian text to speech model demo",
79
- article="",
80
- live=False
81
- )
82
-
83
- iface.launch()