Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
2d0c5b63
Unverified
Commit
2d0c5b63
authored
Jan 09, 2026
by
Isotr0py
Committed by
GitHub
Jan 09, 2026
Browse files
[Doc] Remove hardcoded Whisper in example openai translation client (#32027)
Signed-off-by:
Isotr0py
<
mozf@mail2.sysu.edu.cn
>
parent
34cd32fe
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
+12
-6
examples/online_serving/openai_translation_client.py
examples/online_serving/openai_translation_client.py
+12
-6
No files found.
examples/online_serving/openai_translation_client.py
View file @
2d0c5b63
...
@@ -9,11 +9,11 @@ from openai import OpenAI
...
@@ -9,11 +9,11 @@ from openai import OpenAI
from
vllm.assets.audio
import
AudioAsset
from
vllm.assets.audio
import
AudioAsset
def
sync_openai
(
audio_path
:
str
,
client
:
OpenAI
):
def
sync_openai
(
audio_path
:
str
,
client
:
OpenAI
,
model
:
str
):
with
open
(
audio_path
,
"rb"
)
as
f
:
with
open
(
audio_path
,
"rb"
)
as
f
:
translation
=
client
.
audio
.
translations
.
create
(
translation
=
client
.
audio
.
translations
.
create
(
file
=
f
,
file
=
f
,
model
=
"openai/whisper-large-v3"
,
model
=
model
,
response_format
=
"json"
,
response_format
=
"json"
,
temperature
=
0.0
,
temperature
=
0.0
,
# Additional params not provided by OpenAI API.
# Additional params not provided by OpenAI API.
...
@@ -26,11 +26,13 @@ def sync_openai(audio_path: str, client: OpenAI):
...
@@ -26,11 +26,13 @@ def sync_openai(audio_path: str, client: OpenAI):
print
(
"translation result:"
,
translation
.
text
)
print
(
"translation result:"
,
translation
.
text
)
async
def
stream_openai_response
(
audio_path
:
str
,
base_url
:
str
,
api_key
:
str
):
async
def
stream_openai_response
(
audio_path
:
str
,
base_url
:
str
,
api_key
:
str
,
model
:
str
):
data
=
{
data
=
{
"language"
:
"it"
,
"language"
:
"it"
,
"stream"
:
True
,
"stream"
:
True
,
"model"
:
"openai/whisper-large-v3"
,
"model"
:
model
,
}
}
url
=
base_url
+
"/audio/translations"
url
=
base_url
+
"/audio/translations"
headers
=
{
"Authorization"
:
f
"Bearer
{
api_key
}
"
}
headers
=
{
"Authorization"
:
f
"Bearer
{
api_key
}
"
}
...
@@ -66,9 +68,13 @@ def main():
...
@@ -66,9 +68,13 @@ def main():
api_key
=
openai_api_key
,
api_key
=
openai_api_key
,
base_url
=
openai_api_base
,
base_url
=
openai_api_base
,
)
)
sync_openai
(
foscolo
,
client
)
model
=
client
.
models
.
list
().
data
[
0
].
id
print
(
f
"Using model:
{
model
}
"
)
sync_openai
(
foscolo
,
client
,
model
)
# Run the asynchronous function
# Run the asynchronous function
asyncio
.
run
(
stream_openai_response
(
foscolo
,
openai_api_base
,
openai_api_key
))
asyncio
.
run
(
stream_openai_response
(
foscolo
,
openai_api_base
,
openai_api_key
,
model
))
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
...
...
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