oaattia commited on
Commit
830d400
·
1 Parent(s): 79594c2

Upgrade transformers at runtime for OmniVoice HiggsAudioV2TokenizerModel support

Browse files
Files changed (1) hide show
  1. handler.py +20 -2
handler.py CHANGED
@@ -12,7 +12,13 @@ logger = logging.getLogger(__name__)
12
 
13
  def _install_deps():
14
  """Install OmniVoice and voicetut-tts with --no-deps to avoid conflicts
15
- with the HF Inference Endpoint base image (which pins transformers<5)."""
 
 
 
 
 
 
16
  pkgs = [
17
  "git+https://github.com/k2-fsa/OmniVoice.git",
18
  "voicetut-tts>=0.1.0",
@@ -27,10 +33,22 @@ def _install_deps():
27
  logger.info(f"Installed {pkg}")
28
  except subprocess.CalledProcessError as e:
29
  stderr = e.stderr.decode() if e.stderr else ""
30
- # If already installed, that's fine
31
  if "already satisfied" not in stderr.lower():
32
  logger.warning(f"Failed to install {pkg}: {stderr[:200]}")
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
  # Install deps before importing voicetut_tts
36
  _install_deps()
 
12
 
13
  def _install_deps():
14
  """Install OmniVoice and voicetut-tts with --no-deps to avoid conflicts
15
+ with the HF Inference Endpoint base image.
16
+
17
+ Then upgrade transformers (WITH deps) because OmniVoice needs
18
+ HiggsAudioV2TokenizerModel which only exists in transformers>=4.50.
19
+ The HF Inference Toolkit already loaded successfully with the old
20
+ transformers at this point, so upgrading is safe."""
21
+ # 1. Install OmniVoice and voicetut-tts without their dep trees
22
  pkgs = [
23
  "git+https://github.com/k2-fsa/OmniVoice.git",
24
  "voicetut-tts>=0.1.0",
 
33
  logger.info(f"Installed {pkg}")
34
  except subprocess.CalledProcessError as e:
35
  stderr = e.stderr.decode() if e.stderr else ""
 
36
  if "already satisfied" not in stderr.lower():
37
  logger.warning(f"Failed to install {pkg}: {stderr[:200]}")
38
 
39
+ # 2. Upgrade transformers to get HiggsAudioV2TokenizerModel (needed by OmniVoice)
40
+ try:
41
+ subprocess.check_call(
42
+ [sys.executable, "-m", "pip", "install", "--upgrade",
43
+ "transformers>=4.50.0", "tokenizers>=0.21.0"],
44
+ stdout=subprocess.DEVNULL,
45
+ stderr=subprocess.PIPE,
46
+ )
47
+ logger.info("Upgraded transformers for OmniVoice compatibility")
48
+ except subprocess.CalledProcessError as e:
49
+ stderr = e.stderr.decode() if e.stderr else ""
50
+ logger.warning(f"Failed to upgrade transformers: {stderr[:200]}")
51
+
52
 
53
  # Install deps before importing voicetut_tts
54
  _install_deps()