Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedir Zadniprovskyi committed Nov 1, 2024
1 parent 98ddafa commit 852ad9f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/faster_whisper_server/model_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,21 @@
from typing import TYPE_CHECKING

from faster_whisper import WhisperModel
from piper.voice import PiperVoice

from faster_whisper_server.hf_utils import get_piper_voice_model_file

if TYPE_CHECKING:
from collections.abc import Callable

from piper.voice import PiperVoice

from faster_whisper_server.config import (
WhisperConfig,
)

logger = logging.getLogger(__name__)


# TODO: enable concurrent model downloads


Expand Down Expand Up @@ -147,6 +149,8 @@ def __init__(self, ttl: int) -> None:
self._lock = threading.Lock()

def _load_fn(self, model_id: str) -> PiperVoice:
from piper.voice import PiperVoice

model_path = get_piper_voice_model_file(model_id)
return PiperVoice.load(model_path)

Expand All @@ -163,6 +167,8 @@ def unload_model(self, model_name: str) -> None:
self.loaded_models[model_name].unload()

def load_model(self, model_name: str) -> SelfDisposingModel[PiperVoice]:
from piper.voice import PiperVoice

with self._lock:
if model_name in self.loaded_models:
logger.debug(f"{model_name} model already loaded")
Expand Down

0 comments on commit 852ad9f

Please sign in to comment.