Spaces:
Sleeping
Sleeping
Mejiro J
commited on
Commit
·
21e13bb
1
Parent(s):
bd1a2cc
compatible with cpu instance
Browse files
app.py
CHANGED
@@ -114,7 +114,12 @@ def text2speech(target_text, game, speaker):
|
|
114 |
# Convert token <|s_23456|> to int 23456
|
115 |
speech_tokens = extract_speech_ids(speech_tokens)
|
116 |
|
117 |
-
|
|
|
|
|
|
|
|
|
|
|
118 |
|
119 |
# Decode the speech tokens to speech waveform
|
120 |
gen_wav = Codec_model.decode_code(speech_tokens)
|
|
|
114 |
# Convert token <|s_23456|> to int 23456
|
115 |
speech_tokens = extract_speech_ids(speech_tokens)
|
116 |
|
117 |
+
if torch.cuda.is_available():
|
118 |
+
# Move speech tokens to GPU
|
119 |
+
speech_tokens = torch.tensor(speech_tokens).cuda().unsqueeze(0).unsqueeze(0)
|
120 |
+
else:
|
121 |
+
# If CUDA is not available, keep on CPU
|
122 |
+
speech_tokens = torch.tensor(speech_tokens).unsqueeze(0).unsqueeze(0)
|
123 |
|
124 |
# Decode the speech tokens to speech waveform
|
125 |
gen_wav = Codec_model.decode_code(speech_tokens)
|