Remove multi language feature (Close #23)

This commit is contained in:
Yuta Hayashibe 2022-10-08 00:03:03 +09:00
parent 04bb9f9ad2
commit 526c2ec1d1
3 changed files with 6 additions and 10 deletions

View file

@ -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

View file

@ -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,
)

View file

@ -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