shayekh commited on
Commit
981ecb3
·
verified ·
1 Parent(s): 7f04d37

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -8,6 +8,7 @@ import json
8
  import base64
9
  import soundfile as sf
10
  import torch
 
11
 
12
  from supertonic import TTS
13
  from vllm import LLM, SamplingParams
@@ -38,6 +39,7 @@ def get_base64_image(image):
38
  img_str = base64.b64encode(buffered.getvalue()).decode("utf-8")
39
  return f"data:image/jpeg;base64,{img_str}"
40
 
 
41
  def extract_vocabulary(pdf_text, images, translit_lang, translit_format, target_lang):
42
  """Use vLLM to extract vocabulary from text and images."""
43
  global llm, sampling_params
@@ -116,6 +118,7 @@ def numpy_to_base64_audio(wav, sample_rate):
116
  audio_base64 = base64.b64encode(buffer.read()).decode('utf-8')
117
  return f"data:audio/wav;base64,{audio_base64}"
118
 
 
119
  def process_pdf(pdf_file, translit_lang, translit_format, target_lang):
120
  global tts, voice_style
121
 
@@ -453,7 +456,8 @@ def create_demo():
453
  )
454
  return demo
455
 
456
- if __name__ == "__main__":
 
457
  print("Loading Qwen3.5-2B model via vLLM...")
458
  llm = LLM(
459
  model="Qwen/Qwen3.5-2B",
@@ -485,3 +489,7 @@ if __name__ == "__main__":
485
 
486
  demo = create_demo()
487
  demo.launch(server_name="0.0.0.0", server_port=7861)
 
 
 
 
 
8
  import base64
9
  import soundfile as sf
10
  import torch
11
+ import spaces
12
 
13
  from supertonic import TTS
14
  from vllm import LLM, SamplingParams
 
39
  img_str = base64.b64encode(buffered.getvalue()).decode("utf-8")
40
  return f"data:image/jpeg;base64,{img_str}"
41
 
42
+ @spaces.GPU
43
  def extract_vocabulary(pdf_text, images, translit_lang, translit_format, target_lang):
44
  """Use vLLM to extract vocabulary from text and images."""
45
  global llm, sampling_params
 
118
  audio_base64 = base64.b64encode(buffer.read()).decode('utf-8')
119
  return f"data:audio/wav;base64,{audio_base64}"
120
 
121
+ @spaces.GPU
122
  def process_pdf(pdf_file, translit_lang, translit_format, target_lang):
123
  global tts, voice_style
124
 
 
456
  )
457
  return demo
458
 
459
+ @spaces.GPU
460
+ def main():
461
  print("Loading Qwen3.5-2B model via vLLM...")
462
  llm = LLM(
463
  model="Qwen/Qwen3.5-2B",
 
489
 
490
  demo = create_demo()
491
  demo.launch(server_name="0.0.0.0", server_port=7861)
492
+
493
+
494
+ if __name__ == "__main__":
495
+ main()