TenzinGayche
commited on
Commit
β’
0b0fa8e
1
Parent(s):
4cff53d
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@ import numpy as np
|
|
4 |
import torch
|
5 |
import pyewts
|
6 |
import noisereduce as nr
|
|
|
7 |
def remove_repeated_words(text):
|
8 |
# Tokenize the input text into words
|
9 |
words = text.split()
|
@@ -30,12 +31,6 @@ def remove_repeated_words(text):
|
|
30 |
result = ' '.join(new_words)
|
31 |
return result
|
32 |
|
33 |
-
# Example usage
|
34 |
-
input_text = " hi hi hi are you fine fine fine or not"
|
35 |
-
output_text = remove_repeated_words(input_text)
|
36 |
-
print(output_text)
|
37 |
-
|
38 |
-
from transformers import SpeechT5Processor, SpeechT5ForTextToSpeech, SpeechT5HifiGan
|
39 |
|
40 |
converter = pyewts.pyewts()
|
41 |
checkpoint = "TenzinGayche/TTS_run3_ep20_174k_b"
|
@@ -74,7 +69,7 @@ def predict(text, speaker):
|
|
74 |
# limit input length
|
75 |
input_ids = inputs["input_ids"]
|
76 |
input_ids = input_ids[..., :model.config.max_text_positions]
|
77 |
-
speaker_embedding = np.load(speaker_embeddings[speaker])
|
78 |
speaker_embedding = torch.tensor(speaker_embedding)
|
79 |
speech = model.generate_speech(input_ids.to('cuda'), speaker_embedding.to('cuda'), vocoder=vocoder.to('cuda'))
|
80 |
speech = nr.reduce_noise(y=speech.to('cpu'), sr=16000)
|
|
|
4 |
import torch
|
5 |
import pyewts
|
6 |
import noisereduce as nr
|
7 |
+
from transformers import SpeechT5Processor, SpeechT5ForTextToSpeech, SpeechT5HifiGan
|
8 |
def remove_repeated_words(text):
|
9 |
# Tokenize the input text into words
|
10 |
words = text.split()
|
|
|
31 |
result = ' '.join(new_words)
|
32 |
return result
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
converter = pyewts.pyewts()
|
36 |
checkpoint = "TenzinGayche/TTS_run3_ep20_174k_b"
|
|
|
69 |
# limit input length
|
70 |
input_ids = inputs["input_ids"]
|
71 |
input_ids = input_ids[..., :model.config.max_text_positions]
|
72 |
+
speaker_embedding = np.load(speaker_embeddings[speaker], allow_pickle=True)
|
73 |
speaker_embedding = torch.tensor(speaker_embedding)
|
74 |
speech = model.generate_speech(input_ids.to('cuda'), speaker_embedding.to('cuda'), vocoder=vocoder.to('cuda'))
|
75 |
speech = nr.reduce_noise(y=speech.to('cpu'), sr=16000)
|