[WIP/TEST] faster-whisperが最低限動く形で実装

config.jsonで設定変更で実行可能
This commit is contained in:
misyaguziya
2024-01-30 18:21:55 +09:00
parent ba12e39bbc
commit 9cd1831ecb
8 changed files with 511 additions and 137 deletions

View File

@@ -1,4 +1,8 @@
from pyaudiowpatch import PyAudio, paWASAPI
from faster_whisper.utils import download_model
import logging
logger = logging.getLogger('faster_whisper')
logger.setLevel(logging.CRITICAL)
def getInputDevices():
devices = {}
@@ -44,4 +48,38 @@ def getDefaultOutputDevice():
if default_speakers["name"] in loopback["name"]:
default_device = loopback
return default_device
return {"name":"NoDevice"}
return {"name":"NoDevice"}
def downloadWhisperWeight(weight_type, path):
result = False
try:
download_model(
weight_type,
cache_dir=path)
result = True
except Exception:
pass
return result
def checkWhisperWeight(weight_type, path):
result = False
try:
result = download_model(
weight_type,
local_files_only=True,
cache_dir=path)
result = True
except Exception:
pass
return result
if __name__ == "__main__":
downloadWhisperWeight("base", "./weight/whisper/")
from faster_whisper import WhisperModel
whisper_model = WhisperModel("base", device="cpu", device_index=0, compute_type="int8", cpu_threads=4, num_workers=1, download_root="./weight/whisper/")
print(checkWhisperWeight("base", "./weight/whisper/"))
print(checkWhisperWeight("tiny", "./weight/whisper/"))