ronniet commited on
Commit
b84dff6
·
1 Parent(s): fc3cdd2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -69
app.py CHANGED
@@ -1,82 +1,31 @@
1
  import gradio as gr
2
- from TTS.api import TTS
3
 
4
- tts = TTS(model_name="tts_models/multilingual/multi-dataset/your_tts", progress_bar=False, gpu=False)
5
 
6
- def predict(text):
7
- file_path = "output.wav"
8
- tts.tts_to_file(text, speaker=tts.speakers[0], language="en", file_path=file_path)
9
- return file_path
10
-
11
- demo = gr.Interface(
12
- fn=predict,
13
- inputs='text',
14
- outputs='audio'
15
- )
16
-
17
-
18
- demo.launch()
19
-
20
-
21
- # import requests
22
- # import time
23
- # import tempfile
24
- # import os
25
-
26
- # token = os.environ['apikey']
27
- # #discord_id = os.environ['discord-id']
28
- # API_HOST = "https://labs-proxy.voicemod.net/"
29
-
30
- # def download_file(url):
31
- # response = requests.get(url)
32
- # if response.status_code == 200:
33
- # with tempfile.NamedTemporaryFile(delete=False) as tmp_file:
34
- # tmp_file.write(response.content)
35
- # tmp_file.flush()
36
- # return tmp_file.name
37
- # else:
38
- # print("Error: Unable to download file")
39
-
40
- # def tts(text):
41
- # url = API_HOST + "api/v1/tts/create"
42
- # payload = {
43
- # "text": text[:200] if len(text) > 200 else text,
44
- # "voiceId": "6926ecc5-ff5e-47c6-912b-3ffdb880bf56" # Narrator
45
- # }
46
- # headers = {
47
- # 'x-api-key': token,
48
- # }
49
- # response = requests.request("POST", url, headers=headers, json=payload)
50
- # jsonResp = response.json()
51
-
52
- # return gr.make_waveform(download_file(jsonResp['audioUrl']))
53
 
54
  # demo = gr.Interface(
55
- # fn=tts,
56
- # inputs="text",
57
- # outputs="audio"
58
  # )
59
 
60
- # demo.launch()
61
 
62
- # import openai
63
- # import os
64
- # #from pymongo import MongoClient
65
 
66
- # api_key = os.environ.get("OPENAI_API_KEY")
67
 
68
- # def transcribe_audio(filepath):
69
- # audio = open(filepath, "rb")
70
- # transcript = openai.Audio.transcribe("whisper-1", audio)
71
- # return transcript['text']
72
-
73
 
74
- # # Create a Gradio Tabbed Interface
75
- # iface = gr.Interface(
76
- # fn=transcribe_audio,
77
- # inputs= gr.Audio(source="upload", type="filepath"),
78
- # outputs="text",
79
- # )
80
 
81
 
82
- # iface.launch()
 
 
 
 
1
  import gradio as gr
2
+ # from TTS.api import TTS
3
 
4
+ # tts = TTS(model_name="tts_models/multilingual/multi-dataset/your_tts", progress_bar=False, gpu=False)
5
 
6
+ # def predict(text):
7
+ # file_path = "output.wav"
8
+ # tts.tts_to_file(text, speaker=tts.speakers[0], language="en", file_path=file_path)
9
+ # return file_path
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  # demo = gr.Interface(
12
+ # fn=predict,
13
+ # inputs='text',
14
+ # outputs='audio'
15
  # )
16
 
 
17
 
18
+ # demo.launch()
 
 
19
 
 
20
 
21
+ import librosa
22
+ import numpy as np
23
+ import torch
 
 
24
 
25
+ from transformers import SpeechT5Processor, SpeechT5ForTextToSpeech, SpeechT5HifiGan
 
 
 
 
 
26
 
27
 
28
+ checkpoint = "microsoft/speecht5_tts"
29
+ processor = SpeechT5Processor.from_pretrained(checkpoint)
30
+ model = SpeechT5ForTextToSpeech.from_pretrained(checkpoint)
31
+ vocoder = SpeechT5HifiGan.from_pretrained("microsoft/speecht5_hifigan")