Merge pull request #53 from ahmetoner/add-new-large-model-v2

Add new large model v2
This commit is contained in:
Ahmet Oner
2022-12-08 23:30:15 +01:00
committed by GitHub
4 changed files with 7 additions and 126 deletions

View File

@@ -34,7 +34,7 @@ docker run -d -p 9000:9000 -e ASR_MODEL=base onerahmet/openai-whisper-asr-webser
# Interactive Swagger API documentation is available at http://localhost:9000/docs
```
Available ASR_MODELs are `tiny`, `base`, `small`, `medium` and `large`
Available ASR_MODELs are `tiny`, `base`, `small`, `medium`, `large`, `large-v1` and `large-v2`. Please note that `large` and `large-v2` are the same model.
For English-only applications, the `.en` models tend to perform better, especially for the `tiny.en` and `base.en` models. We observed that the difference becomes less significant for the `small.en` and `medium.en` models.
@@ -64,7 +64,7 @@ poetry install
Starting the Webservice:
```sh
gunicorn --bind 0.0.0.0:9000 --workers 1 --timeout 0 app.webservice:app -k uvicorn.workers.UvicornWorker
gunicorn --bind 0.0.0.0:9001 --workers 1 --timeout 0 app.webservice:app -k uvicorn.workers.UvicornWorker
```
## Quick start

View File

@@ -1,120 +0,0 @@
#from whisper/tokenizer.py
LANGUAGES = {
"en": "english",
"zh": "chinese",
"de": "german",
"es": "spanish",
"ru": "russian",
"ko": "korean",
"fr": "french",
"ja": "japanese",
"pt": "portuguese",
"tr": "turkish",
"pl": "polish",
"ca": "catalan",
"nl": "dutch",
"ar": "arabic",
"sv": "swedish",
"it": "italian",
"id": "indonesian",
"hi": "hindi",
"fi": "finnish",
"vi": "vietnamese",
"iw": "hebrew",
"uk": "ukrainian",
"el": "greek",
"ms": "malay",
"cs": "czech",
"ro": "romanian",
"da": "danish",
"hu": "hungarian",
"ta": "tamil",
"no": "norwegian",
"th": "thai",
"ur": "urdu",
"hr": "croatian",
"bg": "bulgarian",
"lt": "lithuanian",
"la": "latin",
"mi": "maori",
"ml": "malayalam",
"cy": "welsh",
"sk": "slovak",
"te": "telugu",
"fa": "persian",
"lv": "latvian",
"bn": "bengali",
"sr": "serbian",
"az": "azerbaijani",
"sl": "slovenian",
"kn": "kannada",
"et": "estonian",
"mk": "macedonian",
"br": "breton",
"eu": "basque",
"is": "icelandic",
"hy": "armenian",
"ne": "nepali",
"mn": "mongolian",
"bs": "bosnian",
"kk": "kazakh",
"sq": "albanian",
"sw": "swahili",
"gl": "galician",
"mr": "marathi",
"pa": "punjabi",
"si": "sinhala",
"km": "khmer",
"sn": "shona",
"yo": "yoruba",
"so": "somali",
"af": "afrikaans",
"oc": "occitan",
"ka": "georgian",
"be": "belarusian",
"tg": "tajik",
"sd": "sindhi",
"gu": "gujarati",
"am": "amharic",
"yi": "yiddish",
"lo": "lao",
"uz": "uzbek",
"fo": "faroese",
"ht": "haitian creole",
"ps": "pashto",
"tk": "turkmen",
"nn": "nynorsk",
"mt": "maltese",
"sa": "sanskrit",
"lb": "luxembourgish",
"my": "myanmar",
"bo": "tibetan",
"tl": "tagalog",
"mg": "malagasy",
"as": "assamese",
"tt": "tatar",
"haw": "hawaiian",
"ln": "lingala",
"ha": "hausa",
"ba": "bashkir",
"jw": "javanese",
"su": "sundanese",
}
# language code lookup by name, with a few language aliases
TO_LANGUAGE_CODE = {
**{language: code for code, language in LANGUAGES.items()},
"burmese": "my",
"valencian": "ca",
"flemish": "nl",
"haitian": "ht",
"letzeburgesch": "lb",
"pushto": "ps",
"panjabi": "pa",
"moldavian": "ro",
"moldovan": "ro",
"sinhalese": "si",
"castilian": "es",
}
LANGUAGE_CODES = sorted(list(LANGUAGES.keys()))

View File

@@ -4,12 +4,12 @@ from fastapi.staticfiles import StaticFiles
from fastapi.openapi.docs import get_swagger_ui_html
import whisper
from whisper.utils import write_srt, write_vtt
from whisper import tokenizer
import os
from os import path
from pathlib import Path
import ffmpeg
from typing import BinaryIO, Union
from .languages import LANGUAGES, LANGUAGE_CODES
import numpy as np
from io import StringIO
from threading import Lock
@@ -18,6 +18,7 @@ import fastapi_offline_swagger_ui
import importlib.metadata
SAMPLE_RATE=16000
LANGUAGE_CODES=sorted(list(tokenizer.LANGUAGES.keys()))
projectMetadata = importlib.metadata.metadata('whisper-asr-webservice')
app = FastAPI(
@@ -101,7 +102,7 @@ def language_detection(
_, probs = model.detect_language(mel)
detected_lang_code = max(probs, key=probs.get)
result = { "detected_language": LANGUAGES[detected_lang_code],
result = { "detected_language": tokenizer.LANGUAGES[detected_lang_code],
"langauge_code" : detected_lang_code }
return result

View File

@@ -1,6 +1,6 @@
[tool.poetry]
name = "whisper-asr-webservice"
version = "1.0.4"
version = "1.0.5"
description = "Whisper ASR Webservice is a general-purpose speech recognition webservice."
homepage = "https://github.com/ahmetoner/whisper-asr-webservice/"
license = "https://github.com/ahmetoner/whisper-asr-webservice/blob/main/LICENCE"
@@ -16,7 +16,7 @@ python = "^3.9"
unidecode = "^1.3.4"
uvicorn = { extras = ["standard"], version = "^0.18.2" }
gunicorn = "^20.1.0"
whisper = {git = "https://github.com/openai/whisper.git", rev="eff383b27b783e280c089475852ba83f20f64998"}
whisper = {git = "https://github.com/openai/whisper.git", rev="b9265e5796f5d80c18d1f9231ab234225676780b"}
tqdm = "^4.64.1"
transformers = "^4.22.1"
python-multipart = "^0.0.5"