Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
|
| 2 |
from transformers import VitsModel, AutoTokenizer
|
| 3 |
import torch
|
|
|
|
| 4 |
|
| 5 |
model = VitsModel.from_pretrained("facebook/mms-tts-eng")
|
| 6 |
tokenizer = AutoTokenizer.from_pretrained("facebook/mms-tts-eng")
|
|
@@ -8,5 +9,9 @@ tokenizer = AutoTokenizer.from_pretrained("facebook/mms-tts-eng")
|
|
| 8 |
text = "some example text in the English language"
|
| 9 |
inputs = tokenizer(text, return_tensors="pt")
|
| 10 |
|
| 11 |
-
with torch.no_grad():
|
| 12 |
output = model(**inputs).waveform
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
|
| 2 |
from transformers import VitsModel, AutoTokenizer
|
| 3 |
import torch
|
| 4 |
+
import sounddevice as sd # Example: using sounddevice for audio playback
|
| 5 |
|
| 6 |
model = VitsModel.from_pretrained("facebook/mms-tts-eng")
|
| 7 |
tokenizer = AutoTokenizer.from_pretrained("facebook/mms-tts-eng")
|
|
|
|
| 9 |
text = "some example text in the English language"
|
| 10 |
inputs = tokenizer(text, return_tensors="pt")
|
| 11 |
|
| 12 |
+
with torch.no_grad(): # Optionally remove if not needed
|
| 13 |
output = model(**inputs).waveform
|
| 14 |
+
|
| 15 |
+
# Play the generated audio
|
| 16 |
+
sd.play(output.numpy(), samplerate=model.config.audio_config.sampling_rate)
|
| 17 |
+
sd.wait() # Wait for playback to finish
|