[Frontend] add 'verbose_json' and 'timestamp' feature on Whisper Transcription/Translation (#24209)

Signed-off-by: sangbumlikeagod <oironese@naver.com>
Signed-off-by: sangbumlikeagod <98077576+sangbumlikeagod@users.noreply.github.com>
This commit is contained in:
sangbumlikeagod
2025-12-01 18:19:17 +01:00
committed by GitHub
parent 5d43f7372e
commit 092bb73b8a
8 changed files with 224 additions and 23 deletions
@@ -12,10 +12,12 @@ from vllm.entrypoints.openai.protocol import (
TranscriptionRequest,
TranscriptionResponse,
TranscriptionResponseStreamChoice,
TranscriptionResponseVerbose,
TranscriptionStreamResponse,
TranslationRequest,
TranslationResponse,
TranslationResponseStreamChoice,
TranslationResponseVerbose,
TranslationStreamResponse,
)
from vllm.entrypoints.openai.serving_models import OpenAIServingModels
@@ -51,7 +53,12 @@ class OpenAIServingTranscription(OpenAISpeechToText):
async def create_transcription(
self, audio_data: bytes, request: TranscriptionRequest, raw_request: Request
) -> TranscriptionResponse | AsyncGenerator[str, None] | ErrorResponse:
) -> (
TranscriptionResponse
| TranscriptionResponseVerbose
| AsyncGenerator[str, None]
| ErrorResponse
):
"""Transcription API similar to OpenAI's API.
See https://platform.openai.com/docs/api-reference/audio/createTranscription
@@ -61,7 +68,11 @@ class OpenAIServingTranscription(OpenAISpeechToText):
audio_data=audio_data,
request=request,
raw_request=raw_request,
response_class=TranscriptionResponse,
response_class=(
TranscriptionResponseVerbose
if request.response_format == "verbose_json"
else TranscriptionResponse
),
stream_generator_method=self.transcription_stream_generator,
)
@@ -112,7 +123,12 @@ class OpenAIServingTranslation(OpenAISpeechToText):
async def create_translation(
self, audio_data: bytes, request: TranslationRequest, raw_request: Request
) -> TranslationResponse | AsyncGenerator[str, None] | ErrorResponse:
) -> (
TranslationResponse
| TranslationResponseVerbose
| AsyncGenerator[str, None]
| ErrorResponse
):
"""Translation API similar to OpenAI's API.
See https://platform.openai.com/docs/api-reference/audio/createTranslation
@@ -122,7 +138,11 @@ class OpenAIServingTranslation(OpenAISpeechToText):
audio_data=audio_data,
request=request,
raw_request=raw_request,
response_class=TranslationResponse,
response_class=(
TranslationResponseVerbose
if request.response_format == "verbose_json"
else TranslationResponse
),
stream_generator_method=self.translation_stream_generator,
)