collabora / WhisperSpeech

An Open Source text-to-speech system built by inverting Whisper.
https://collabora.github.io/WhisperSpeech/
MIT License
3.8k stars 207 forks source link

Add cache dir parameter #144

Open BBC-Esq opened 3 months ago

BBC-Esq commented 3 months ago

The goal is to be able to specify the base directory in which all files downloaded from huggingface are downloaded instead of the default cache directory.

Some sample code might look like this:

from pathlib import Path

current_directory = Path(__file__).parent
CACHE_DIR = current_directory / "models" / "tts"
CACHE_DIR.mkdir(parents=True, exist_ok=True)

class BaseAudio:
.
.
.

class WhisperSpeechAudio(BaseAudio):
    def __init__(self):
        super().__init__()
        self.initialize_model()

    def initialize_model(self):

        self.pipe = Pipeline(
            s2a_ref='collabora/whisperspeech:s2a-q4-base-en+pl.model',
            t2s_ref='collabora/whisperspeech:t2s-base-en+pl.model',
            cache_dir=CACHE_DIR
        )
.
.
.