Skip to content

Commit

Permalink
examples of transcribe methods in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiltseb committed Nov 1, 2024
1 parent c5b28c1 commit bafb279
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions docs/pages/model_hub/asr.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,55 @@ Here are some other possible configurations for the Whisper deployment:
)
```

### Examples of Transcription from Video

Let's see different transcribe methods in the transcription endpoint class.

!!! example "Transcribe methods in Aana SDK"

```python
from aana.core.models.video import VideoInput
from aana.core.models.whisper import BatchedWhisperParams, WhisperParams
from aana.deployments.whisper_deployment import WhisperOutput

async def run(
self,
video: VideoInput,
whisper_params: WhisperParams,
) -> WhisperOutput:

#Download video and extract audio
video_obj = await run_remote(download_video)(video_input=video)
audio = extract_audio(video=video_obj)
#1. Method "transcribe":
# Use to get the full transcription output at the end all at once.
transcription = await self.asr_handle.transcribe(
audio=audio, params=whisper_params
)
#further processing...


#2. Method "transcribe_stream":
# Use to get transcription segment-by-segment as they become available.
stream = handle.transcribe_stream(
audio=audio, params=WhisperParams
)
async for chunk in stream:
#further processing...


#3. Method "transcribe_in_chunks":
# Perform batched inference and returns one batch of segments at a time.
# 4x faster than sequential methods.
batched_stream = handle.transcribe_in_chunks(
audio=audio,
params=BatchedWhisperParams(),
)
async for chunk in batched_stream:
#further processing...
```

### Diarized ASR

Diarized transcription can be generated by using [WhisperDeployment](./../../reference/deployments.md#aana.deployments.WhisperDeployment) and [PyannoteSpeakerDiarizationDeployment](./../../reference/deployments.md#aana.deployments.PyannoteSpeakerDiarizationDeployment) and combining the timelines using post processing with [PostProcessingForDiarizedAsr](./../../reference/processors.md#aana.processors.speaker.PostProcessingForDiarizedAsr).
Expand Down

0 comments on commit bafb279

Please sign in to comment.