Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
b5d88260
Unverified
Commit
b5d88260
authored
Apr 14, 2024
by
Timothy Jaeryang Baek
Committed by
GitHub
Apr 14, 2024
Browse files
Merge pull request #1499 from lainedfles/whisper_auto_update
feat: introduce Whisper model auto-update control.
parents
d9ce1d3e
faa58841
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
6 deletions
+22
-6
backend/apps/audio/main.py
backend/apps/audio/main.py
+19
-6
backend/config.py
backend/config.py
+3
-0
No files found.
backend/apps/audio/main.py
View file @
b5d88260
...
@@ -28,6 +28,7 @@ from config import (
...
@@ -28,6 +28,7 @@ from config import (
UPLOAD_DIR
,
UPLOAD_DIR
,
WHISPER_MODEL
,
WHISPER_MODEL
,
WHISPER_MODEL_DIR
,
WHISPER_MODEL_DIR
,
WHISPER_MODEL_AUTO_UPDATE
,
DEVICE_TYPE
,
DEVICE_TYPE
,
)
)
...
@@ -69,12 +70,24 @@ def transcribe(
...
@@ -69,12 +70,24 @@ def transcribe(
f
.
write
(
contents
)
f
.
write
(
contents
)
f
.
close
()
f
.
close
()
model
=
WhisperModel
(
whisper_kwargs
=
{
WHISPER_MODEL
,
"model_size_or_path"
:
WHISPER_MODEL
,
device
=
whisper_device_type
,
"device"
:
whisper_device_type
,
compute_type
=
"int8"
,
"compute_type"
:
"int8"
,
download_root
=
WHISPER_MODEL_DIR
,
"download_root"
:
WHISPER_MODEL_DIR
,
)
"local_files_only"
:
not
WHISPER_MODEL_AUTO_UPDATE
,
}
log
.
debug
(
f
"whisper_kwargs:
{
whisper_kwargs
}
"
)
try
:
model
=
WhisperModel
(
**
whisper_kwargs
)
except
:
log
.
warning
(
"WhisperModel initialization failed, attempting download with local_files_only=False"
)
whisper_kwargs
[
"local_files_only"
]
=
False
model
=
WhisperModel
(
**
whisper_kwargs
)
segments
,
info
=
model
.
transcribe
(
file_path
,
beam_size
=
5
)
segments
,
info
=
model
.
transcribe
(
file_path
,
beam_size
=
5
)
log
.
info
(
log
.
info
(
...
...
backend/config.py
View file @
b5d88260
...
@@ -450,6 +450,9 @@ Query: [query]"""
...
@@ -450,6 +450,9 @@ Query: [query]"""
WHISPER_MODEL
=
os
.
getenv
(
"WHISPER_MODEL"
,
"base"
)
WHISPER_MODEL
=
os
.
getenv
(
"WHISPER_MODEL"
,
"base"
)
WHISPER_MODEL_DIR
=
os
.
getenv
(
"WHISPER_MODEL_DIR"
,
f
"
{
CACHE_DIR
}
/whisper/models"
)
WHISPER_MODEL_DIR
=
os
.
getenv
(
"WHISPER_MODEL_DIR"
,
f
"
{
CACHE_DIR
}
/whisper/models"
)
WHISPER_MODEL_AUTO_UPDATE
=
(
os
.
environ
.
get
(
"WHISPER_MODEL_AUTO_UPDATE"
,
""
).
lower
()
==
"true"
)
####################################
####################################
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment