Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
whisper-asr-webservice
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Schwertgen
whisper-asr-webservice
Commits
a6169fb6
Commit
a6169fb6
authored
9 months ago
by
Ahmet Öner
Browse files
Options
Downloads
Patches
Plain Diff
Improve application start method
parent
37f1bb26
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
Dockerfile
+1
-1
1 addition, 1 deletion
Dockerfile
Dockerfile.gpu
+1
-1
1 addition, 1 deletion
Dockerfile.gpu
app/webservice.py
+30
-3
30 additions, 3 deletions
app/webservice.py
docs/build.md
+1
-1
1 addition, 1 deletion
docs/build.md
with
33 additions
and
6 deletions
Dockerfile
+
1
−
1
View file @
a6169fb6
...
...
@@ -63,4 +63,4 @@ RUN poetry install
EXPOSE
9000
ENTRYPOINT
["
gunicorn", "--bind", "0.0.0.0:9000", "--workers", "1", "--timeout", "0", "app.webservice:app", "-k", "uvicorn.workers.UvicornWorker
"]
ENTRYPOINT
["
whisper-asr-webservice
"]
This diff is collapsed.
Click to expand it.
Dockerfile.gpu
+
1
−
1
View file @
a6169fb6
...
...
@@ -81,4 +81,4 @@ RUN $POETRY_VENV/bin/pip install torch==1.13.1+cu117 -f https://download.pytorch
EXPOSE 9000
CMD
gunicorn --bind 0.0.0.0:9000 --workers 1 --timeout 0 app.webservice:app -k uvicorn.workers.UvicornWorker
CMD
whisper-asr-webservice
This diff is collapsed.
Click to expand it.
app/webservice.py
+
30
−
3
View file @
a6169fb6
import
importlib.metadata
import
os
from
os
import
path
from
typing
import
Annotated
,
BinaryIO
,
Union
from
typing
import
Annotated
,
BinaryIO
,
Optional
,
Union
from
urllib.parse
import
quote
import
click
import
ffmpeg
import
numpy
as
np
import
uvicorn
from
fastapi
import
FastAPI
,
File
,
Query
,
UploadFile
,
applications
from
fastapi.openapi.docs
import
get_swagger_ui_html
from
fastapi.responses
import
RedirectResponse
,
StreamingResponse
...
...
@@ -14,9 +16,9 @@ from whisper import tokenizer
ASR_ENGINE
=
os
.
getenv
(
"
ASR_ENGINE
"
,
"
openai_whisper
"
)
if
ASR_ENGINE
==
"
faster_whisper
"
:
from
.faster_whisper.core
import
language_detection
,
transcribe
from
app
.faster_whisper.core
import
language_detection
,
transcribe
else
:
from
.openai_whisper.core
import
language_detection
,
transcribe
from
app
.openai_whisper.core
import
language_detection
,
transcribe
SAMPLE_RATE
=
16000
LANGUAGE_CODES
=
sorted
(
tokenizer
.
LANGUAGES
.
keys
())
...
...
@@ -122,3 +124,28 @@ def load_audio(file: BinaryIO, encode=True, sr: int = SAMPLE_RATE):
out
=
file
.
read
()
return
np
.
frombuffer
(
out
,
np
.
int16
).
flatten
().
astype
(
np
.
float32
)
/
32768.0
@click.command
()
@click.option
(
"
-h
"
,
"
--host
"
,
metavar
=
"
HOST
"
,
default
=
"
0.0.0.0
"
,
help
=
"
Host for the webservice (default: 0.0.0.0)
"
,
)
@click.option
(
"
-p
"
,
"
--port
"
,
metavar
=
"
PORT
"
,
default
=
9000
,
help
=
"
Port for the webservice (default: 9000)
"
,
)
@click.version_option
(
version
=
projectMetadata
[
"
Version
"
])
def
start
(
host
:
str
,
port
:
Optional
[
int
]
=
None
):
uvicorn
.
run
(
app
,
host
=
host
,
port
=
port
)
if
__name__
==
"
__main__
"
:
start
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
docs/build.md
+
1
−
1
View file @
a6169fb6
...
...
@@ -24,7 +24,7 @@ poetry install
Starting the Webservice:
```
sh
poetry run
gunicorn
--bind
0.0.0.0
:9000
--
w
or
kers
1
--timeout
0 app.webservice:app
-k
uvicorn.workers.UvicornWorker
poetry run
whisper-asr-webservice
--host
0.0.0.0
--
p
or
t
9000
```
### Build
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment