potsawee commited on
Commit
f73992a
·
verified ·
1 Parent(s): c3d23ec

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +14 -0
app.py CHANGED
@@ -33,6 +33,18 @@ from transformers import (
33
  MimiModel,
34
  )
35
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  # Constants
38
  SAMPLE_RATE = 24000
@@ -241,6 +253,7 @@ def generate_tts_audio(text: str, voice: str, instructions: str = None) -> str:
241
  return temp_file.name
242
 
243
 
 
244
  def process_inputs(transcript_text: str, voice1: str, voice2: str, instructions1: str = "", instructions2: str = ""):
245
  """Process inputs and generate audio."""
246
  if not all([model, mimi_model, tokenizer, feature_extractor, openai_client]):
@@ -318,6 +331,7 @@ def process_inputs(transcript_text: str, voice1: str, voice2: str, instructions1
318
  )
319
 
320
 
 
321
  def swap_embeddings(embeddings_json: str, swap_indices: str):
322
  """Perform embedding swap at specified token indices."""
323
  if not embeddings_json:
 
33
  MimiModel,
34
  )
35
 
36
+ # Import spaces for GPU support
37
+ try:
38
+ import spaces
39
+ GPU_AVAILABLE = True
40
+ except ImportError:
41
+ GPU_AVAILABLE = False
42
+ # Create dummy decorator if spaces not available
43
+ class spaces:
44
+ @staticmethod
45
+ def GPU(func):
46
+ return func
47
+
48
 
49
  # Constants
50
  SAMPLE_RATE = 24000
 
253
  return temp_file.name
254
 
255
 
256
+ @spaces.GPU
257
  def process_inputs(transcript_text: str, voice1: str, voice2: str, instructions1: str = "", instructions2: str = ""):
258
  """Process inputs and generate audio."""
259
  if not all([model, mimi_model, tokenizer, feature_extractor, openai_client]):
 
331
  )
332
 
333
 
334
+ @spaces.GPU
335
  def swap_embeddings(embeddings_json: str, swap_indices: str):
336
  """Perform embedding swap at specified token indices."""
337
  if not embeddings_json: