[Model] Support languages added by fine-tuned Qwen3-TTS checkpoints (#4210)
Signed-off-by: lokesh <lokesh.v9911@gmail.com>
This commit is contained in:
1 parent
4d71a162e6
commit
176b00538c
3 files changed
+109
-17
No files matched your search
@@ -9,6 +9,7 @@ import re
|
||||
import struct
|
||||
import time
|
||||
from collections import OrderedDict
|
||||
from collections.abc import Mapping
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from http import HTTPStatus
|
||||
from pathlib import Path
|
||||
@@ -102,19 +103,21 @@ _SAMPLING_MAX_TOKENS_TTS_MODEL_TYPES = {
|
||||
"higgs_audio_v2",
|
||||
"higgs_audio_v3",
|
||||
}
|
||||
_TTS_LANGUAGES: set[str] = {
|
||||
"Auto",
|
||||
"Chinese",
|
||||
"English",
|
||||
"Japanese",
|
||||
"Korean",
|
||||
"German",
|
||||
"French",
|
||||
"Russian",
|
||||
"Portuguese",
|
||||
"Spanish",
|
||||
"Italian",
|
||||
}
|
||||
_TTS_LANGUAGES = frozenset(
|
||||
{
|
||||
"Auto",
|
||||
"Chinese",
|
||||
"English",
|
||||
"Japanese",
|
||||
"Korean",
|
||||
"German",
|
||||
"French",
|
||||
"Russian",
|
||||
"Portuguese",
|
||||
"Spanish",
|
||||
"Italian",
|
||||
}
|
||||
)
|
||||
_REF_AUDIO_MIN_DURATION = 1.0 # seconds
|
||||
_REF_AUDIO_MAX_DURATION = 30.0 # seconds
|
||||
_REF_AUDIO_RESOLVE_CACHE_MAX_ENTRIES = 256
|
||||
@@ -434,6 +437,9 @@ class OmniOpenAIServingSpeech(OpenAIServing, AudioMixin):
|
||||
# Merge built-in speakers into the set initialized by _init_speaker_storage.
|
||||
self.supported_speakers |= self._load_supported_speakers()
|
||||
self.supported_speakers |= set(self.precomputed_speakers)
|
||||
|
||||
self.supported_languages = self._load_supported_languages()
|
||||
|
||||
self._tts_tokenizer = None
|
||||
self._voxcpm2_tokenizer = None
|
||||
self._voxcpm2_split_map: dict[int, list[int]] = {}
|
||||
@@ -694,6 +700,26 @@ class OmniOpenAIServingSpeech(OpenAIServing, AudioMixin):
|
||||
|
||||
return set()
|
||||
|
||||
def _load_supported_languages(self) -> frozenset[str]:
|
||||
"""Load supported languages (title-cased) from the model configuration"""
|
||||
if self._tts_model_type != "qwen3_tts":
|
||||
return _TTS_LANGUAGES
|
||||
try:
|
||||
config = self.engine_client.model_config.hf_config.talker_config
|
||||
|
||||
if isinstance(config, dict):
|
||||
codec_language_id = config.get("codec_language_id")
|
||||
else:
|
||||
codec_language_id = getattr(config, "codec_language_id", None)
|
||||
|
||||
if codec_language_id and isinstance(codec_language_id, Mapping):
|
||||
return frozenset(str(language).title() for language in codec_language_id) | {"Auto"}
|
||||
|
||||
logger.warning("No codec_language_id found in talker_config; falling back to default languages")
|
||||
except Exception as e:
|
||||
logger.warning("Could not load languages from model config: %s", e)
|
||||
return _TTS_LANGUAGES
|
||||
|
||||
def _estimate_ref_code_len(self, ref_audio: object) -> int | None:
|
||||
"""Estimate ref_code length from ref_audio waveform without running the codec.
|
||||
|
||||
@@ -1420,9 +1446,13 @@ class OmniOpenAIServingSpeech(OpenAIServing, AudioMixin):
|
||||
if not request.input or not request.input.strip():
|
||||
return "Input text cannot be empty"
|
||||
|
||||
# Validate language
|
||||
if request.language is not None and request.language not in _TTS_LANGUAGES:
|
||||
return f"Invalid language '{request.language}'. Supported: {', '.join(sorted(_TTS_LANGUAGES))}"
|
||||
# Validate language (case-insensitive; normalized to the title-cased config form)
|
||||
if request.language is not None:
|
||||
request.language = request.language.title()
|
||||
if request.language not in self.supported_languages:
|
||||
return (
|
||||
f"Invalid language '{request.language}'. Supported: {', '.join(sorted(self.supported_languages))}"
|
||||
)
|
||||
|
||||
# Validate speaker for CustomVoice task
|
||||
if task_type == "CustomVoice":
|
||||
|
||||
Reference in new issue
Block a user