Support multilingual whisper models (#274)
This commit is contained in:
@@ -17,6 +17,21 @@ void OfflineWhisperModelConfig::Register(ParseOptions *po) {
|
||||
po->Register("whisper-decoder", &decoder,
|
||||
"Path to onnx decoder of whisper, e.g., tiny-decoder.onnx, "
|
||||
"medium.en-decoder.onnx.");
|
||||
|
||||
po->Register(
|
||||
"whisper-language", &language,
|
||||
"The spoke language in the input audio file. Example values: "
|
||||
"en, de, fr, zh, jp. If it is not given for a multilingual model, we will"
|
||||
" infer the language from the input audio file. "
|
||||
"Please refer to "
|
||||
"https://github.com/openai/whisper/blob/main/whisper/tokenizer.py#L10"
|
||||
" for valid values. Note that for non-multilingual models, it supports "
|
||||
"only 'en'");
|
||||
|
||||
po->Register("whisper-task", &task,
|
||||
"Valid values: transcribe, translate. "
|
||||
"Note that for non-multilingual models, it supports "
|
||||
"only 'transcribe'");
|
||||
}
|
||||
|
||||
bool OfflineWhisperModelConfig::Validate() const {
|
||||
@@ -30,6 +45,14 @@ bool OfflineWhisperModelConfig::Validate() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (task != "translate" && task != "transcribe") {
|
||||
SHERPA_ONNX_LOGE(
|
||||
"--whisper-task supports only translate and transcribe. Given: %s",
|
||||
task.c_str());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -38,7 +61,9 @@ std::string OfflineWhisperModelConfig::ToString() const {
|
||||
|
||||
os << "OfflineWhisperModelConfig(";
|
||||
os << "encoder=\"" << encoder << "\", ";
|
||||
os << "decoder=\"" << decoder << "\")";
|
||||
os << "decoder=\"" << decoder << "\", ";
|
||||
os << "language=\"" << language << "\", ";
|
||||
os << "task=\"" << task << "\")";
|
||||
|
||||
return os.str();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user