From 526c2ec1d127556ec39ce9884f17aaa77903f25d Mon Sep 17 00:00:00 2001 From: Yuta Hayashibe Date: Sat, 8 Oct 2022 00:03:03 +0900 Subject: [PATCH] Remove multi language feature (Close #23) --- README.md | 2 +- whispering/cli.py | 8 +++----- whispering/schema.py | 6 ++---- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index edae52a..6529e48 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ whispering --language en --model tiny - ``--help`` shows full options - ``--model`` set the [model name](https://github.com/openai/whisper#available-models-and-languages) to use. Larger models will be more accurate, but may not be able to transcribe in real time. -- ``--language`` sets the language to transcribe. Use ``multi`` for multi languages. The list of languages are shown with ``whispering -h`` +- ``--language`` sets the language to transcribe. The list of languages are shown with ``whispering -h`` - ``--no-progress`` disables the progress message - ``-t`` sets temperatures to decode. You can set several like ``-t 0.0 -t 0.1 -t 0.5``, but too many temperatures exhaust decoding time - ``--debug`` outputs logs for debug diff --git a/whispering/cli.py b/whispering/cli.py index e8d02a6..2f53a49 100644 --- a/whispering/cli.py +++ b/whispering/cli.py @@ -16,7 +16,7 @@ from whisper.audio import N_FRAMES, SAMPLE_RATE from whisper.tokenizer import LANGUAGES, TO_LANGUAGE_CODE from whispering.pbar import ProgressBar -from whispering.schema import MULTI_LANGUAGE, Context, StdoutWriter, WhisperConfig +from whispering.schema import Context, StdoutWriter, WhisperConfig from whispering.serve import serve_with_websocket from whispering.transcriber import WhisperStreamingTranscriber from whispering.websocket_client import run_websocket_client @@ -105,9 +105,7 @@ def get_opts() -> argparse.Namespace: group_model.add_argument( "--language", type=str, - default=None, - choices=[MULTI_LANGUAGE] - + sorted(LANGUAGES.keys()) + choices=sorted(LANGUAGES.keys()) + sorted([k.title() for k in TO_LANGUAGE_CODE.keys()]), ) group_model.add_argument( @@ -206,7 +204,7 @@ def get_opts() -> argparse.Namespace: def get_wshiper(*, opts) -> WhisperStreamingTranscriber: config = WhisperConfig( model_name=opts.model, - language=None if opts.language == MULTI_LANGUAGE else opts.language, + language=opts.language, device=opts.device, ) diff --git a/whispering/schema.py b/whispering/schema.py index 3f697c0..e805f73 100644 --- a/whispering/schema.py +++ b/whispering/schema.py @@ -1,19 +1,17 @@ #!/usr/bin/env python3 import sys -from typing import Final, List, Optional +from typing import List, Optional import numpy as np import torch from pydantic import BaseModel, root_validator -MULTI_LANGUAGE: Final[str] = "multi" - class WhisperConfig(BaseModel): model_name: str device: str - language: Optional[str] + language: str fp16: bool = True @root_validator