Abrahamau commited on
Commit
27c643e
·
verified ·
1 Parent(s): e093a97

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -10,6 +10,7 @@ from diffusers import DiffusionPipeline
10
  from huggingface_hub import login
11
  import numpy as np
12
  import spaces
 
13
 
14
  @spaces.GPU
15
  def guessanImage(model, image):
@@ -27,12 +28,14 @@ def guessanAge(model, image):
27
 
28
  @spaces.GPU(duration=120)
29
  def text2speech(text, no, sample):
 
30
  os.environ["COQUI_TOS_AGREED"] = "1"
31
  if sample is None:
32
  sample = "sampleaudio/abraham.wav"
33
  if len(text) > 0:
 
34
  tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2")
35
- wav = tts.tts_to_file(text=text, file_path="output.wav", speaker_wav=sample, language="en")
36
  return wav
37
 
38
  @spaces.GPU
 
10
  from huggingface_hub import login
11
  import numpy as np
12
  import spaces
13
+ import time
14
 
15
  @spaces.GPU
16
  def guessanImage(model, image):
 
28
 
29
  @spaces.GPU(duration=120)
30
  def text2speech(text, no, sample):
31
+ device = "cuda" if torch.cuda.is_available() else "cpu"
32
  os.environ["COQUI_TOS_AGREED"] = "1"
33
  if sample is None:
34
  sample = "sampleaudio/abraham.wav"
35
  if len(text) > 0:
36
+ epoch_time = int(time.time())
37
  tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2")
38
+ wav = tts.tts_to_file(text=text, file_path="output-"+epoch_time+".wav", speaker_wav=sample, language="en").to(device)
39
  return wav
40
 
41
  @spaces.GPU