Skip to content

Commit

Permalink
Merge pull request #9 from idiap/fix-language-manager
Browse files Browse the repository at this point in the history
fix(LanguageManager): allow initialisation from config with language ids file
  • Loading branch information
eginhard authored Apr 23, 2024
2 parents 5527f70 + 52a52b5 commit d65ba4a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions TTS/tts/utils/languages.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from typing import Any, Dict, List
from typing import Any, Dict, List, Optional

import fsspec
import numpy as np
Expand Down Expand Up @@ -85,18 +85,18 @@ def save_ids_to_file(self, file_path: str) -> None:
self._save_json(file_path, self.name_to_id)

@staticmethod
def init_from_config(config: Coqpit) -> "LanguageManager":
def init_from_config(config: Coqpit) -> Optional["LanguageManager"]:
"""Initialize the language manager from a Coqpit config.
Args:
config (Coqpit): Coqpit config.
"""
language_manager = None
if check_config_and_model_args(config, "use_language_embedding", True):
if config.get("language_ids_file", None):
language_manager = LanguageManager(language_ids_file_path=config.language_ids_file)
language_manager = LanguageManager(config=config)
return language_manager
return LanguageManager(language_ids_file_path=config.language_ids_file)
# Fall back to parse language IDs from the config
return LanguageManager(config=config)
return None


def _set_file_path(path):
Expand Down

0 comments on commit d65ba4a

Please sign in to comment.