s3nh commited on
Commit
7c8b7dc
·
verified ·
1 Parent(s): 9702e1d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -1,4 +1,4 @@
1
-
2
  import spaces
3
  import soundfile as sf
4
  import torch
@@ -12,8 +12,6 @@ from transformers import AutoModelForCausalLM, AutoTokenizer, VitsModel
12
  import torch
13
  import numpy as np
14
  import os
15
- import argparse
16
- import gradio as gr
17
  from timeit import default_timer as timer
18
  import torch
19
  import numpy as np
@@ -26,7 +24,6 @@ import whisper
26
  # tts_model.to("cuda")
27
  # print("TTS Loaded!")
28
 
29
-
30
  def load_whisper():
31
  return whisper.load_model("medium", device = 'cpu')
32
 
@@ -100,6 +97,8 @@ def _parse_text(text):
100
  lines[i] = "<br>" + line
101
  text = "".join(lines)
102
  return text
 
 
103
  @spaces.GPU
104
  def predict(_query, _chatbot, _task_history):
105
  print(f"User: {_parse_text(_query)}")
@@ -116,6 +115,7 @@ def predict(_query, _chatbot, _task_history):
116
  _task_history.append((_query, full_response))
117
  print(f"Qwen-7B-Chat: {_parse_text(full_response)}")
118
 
 
119
  def read_text(text):
120
  print("___Tekst do przeczytania!")
121
  inputs = tokenizer_tss(text, return_tensors="pt").to("cuda")
@@ -127,7 +127,7 @@ def read_text(text):
127
 
128
  def update_audio(text):
129
  return 'temp_file.wav'
130
-
131
  def translate(audio):
132
  print("__Wysyłam nagranie do whisper!")
133
  transcription = whisper_model.transcribe(audio, language="pl")
 
1
+ import gradio as gr
2
  import spaces
3
  import soundfile as sf
4
  import torch
 
12
  import torch
13
  import numpy as np
14
  import os
 
 
15
  from timeit import default_timer as timer
16
  import torch
17
  import numpy as np
 
24
  # tts_model.to("cuda")
25
  # print("TTS Loaded!")
26
 
 
27
  def load_whisper():
28
  return whisper.load_model("medium", device = 'cpu')
29
 
 
97
  lines[i] = "<br>" + line
98
  text = "".join(lines)
99
  return text
100
+
101
+
102
  @spaces.GPU
103
  def predict(_query, _chatbot, _task_history):
104
  print(f"User: {_parse_text(_query)}")
 
115
  _task_history.append((_query, full_response))
116
  print(f"Qwen-7B-Chat: {_parse_text(full_response)}")
117
 
118
+ @spaces.GPU
119
  def read_text(text):
120
  print("___Tekst do przeczytania!")
121
  inputs = tokenizer_tss(text, return_tensors="pt").to("cuda")
 
127
 
128
  def update_audio(text):
129
  return 'temp_file.wav'
130
+ @spaces.GPU
131
  def translate(audio):
132
  print("__Wysyłam nagranie do whisper!")
133
  transcription = whisper_model.transcribe(audio, language="pl")