Setting the file. One moment.
Subchapter 150.16
examples/transcription.mdMarkdown12 KBView on GitHub
Complete working code for real-time speech-to-text transcription.
Official Sample: VSDK_TranscriptionAndTranslation in videosdk-windows-rawdata-sample
Live transcription provides real-time captions of speech. Features:
┌─────────────────────────────────────────────────────────────────┐
│ TRANSCRIPTION FLOW │
├─────────────────────────────────────────────────────────────────┤
│ 1. Enable transcription → startLiveTranscription() │
│ 2. Receive captions → onLiveTranscriptionMsgInfoReceived() │
│ 3. Display/process text │
└─────────────────────────────────────────────────────────────────┘#pragma once
#include <windows.h>
#include <string>
#include <vector>
#include <functional>
#include "zoom_video_sdk_interface.h"
USING_ZOOM_VIDEO_SDK_NAMESPACE
struct TranscriptionMessage {
std::wstring speakerName;
std::wstring text;
bool isFinal;
unsigned long long timestamp;
};
class TranscriptionManager {
public:
TranscriptionManager(IZoomVideoSDK* sdk);
// Control
bool StartTranscription();
bool StopTranscription();
bool IsTranscribing() const { return m_isTranscribing; }
// Language settings
bool SetSpokenLanguage(ILiveTranscriptionLanguage* language);
bool SetTranslationLanguage(ILiveTranscriptionLanguage* language);
std::vector<ILiveTranscriptionLanguage*> GetAvailableLanguages();
// Callbacks from delegate
void OnStatusChanged(ZoomVideoSDKLiveTranscriptionStatus status);
void OnMessageReceived(ILiveTranscriptionMessageInfo* info);
void OnOriginalLanguageReceived(ILiveTranscriptionMessageInfo* info);
void OnError(ILiveTranscriptionLanguage* spoken,
ILiveTranscriptionLanguage* transcript);
// Set message handler
using MessageCallback = std::function<void(const TranscriptionMessage&)>;
void SetMessageHandler(MessageCallback callback) { m_callback = callback; }
private:
IZoomVideoSDK* m_sdk;
IZoomVideoSDKLiveTranscriptionHelper* m_helper;
bool m_isTranscribing;
MessageCallback m_callback;
};#include "TranscriptionManager.h"
#include <iostream>
TranscriptionManager::TranscriptionManager(IZoomVideoSDK* sdk)
: m_sdk(sdk)
, m_helper(nullptr)
, m_isTranscribing(false) {
}
bool TranscriptionManager::StartTranscription() {
m_helper = m_sdk->getLiveTranscriptionHelper();
if (
class MyDelegate : public IZoomVideoSDKDelegate {
private:
TranscriptionManager* m_transcription;
public:
MyDelegate(IZoomVideoSDK* sdk) {
m_transcription = new TranscriptionManager(sdk);
// Set message handler
m_transcription->SetMessageHandler([](const TranscriptionMessage& msg) {
// Process transcription (e.g., save to file, analyze)
if (msg.isFinal) {
SaveTranscript(msg.speakerName, msg.text);
}
});
}
void onSessionJoin() override {
// Start transcription
m_transcription->StartTranscription();
}
void onLiveTranscriptionStatus(ZoomVideoSDKLiveTranscriptionStatus status) override {
m_transcription->OnStatusChanged(status);
}
void onLiveTranscriptionMsgInfoReceived(ILiveTranscriptionMessageInfo* info) override {
m_transcription->OnMessageReceived(info);
}
void onOriginalLanguageMsgReceived(ILiveTranscriptionMessageInfo* info) override {
m_transcription->OnOriginalLanguageReceived(info);
}
void onLiveTranscriptionMsgError(ILiveTranscriptionLanguage* spoken,
ILiveTranscriptionLanguage* transcript) override {
m_transcription->OnError(spoken, transcript);
}
// ... other callbacks
};| Type | Description |
|---|---|
ZoomVideoSDKLiveTranscriptionOperationType_N | Interim result (may change) |
ZoomVideoSDKLiveTranscriptionOperationType_Complete | Final result |
ZoomVideoSDKLiveTranscriptionOperationType_Update | Updated previous result |
Note: Interim results allow real-time display but may be revised.
| Method | Returns | Description |
|---|---|---|
getMessageContent() | const zchar_t* | Transcribed text |
getSpeaker() | IZoomVideoSDKUser* | Speaker user object |
getTimeStamp() | unsigned long long | Message timestamp |
getMessageType() | ZoomVideoSDKLiveTranscriptionOperationType | Interim/final |
getMessageID() | const zchar_t* | Unique message ID |
auto languages = transcriptionManager->GetAvailableLanguages();
for (auto lang : languages) {
std::wcout << lang->getLTTLanguageID() << L": "
<< lang->getLTTLanguageName() << std::endl;
}| Code | Language |
|---|---|
en | English |
es | Spanish |
fr | French |
de | German |
zh | Chinese |
ja | Japanese |
Cause: Feature not enabled for session
Fix: Check canStartLiveTranscription() first:
if (helper->canStartLiveTranscription()) {
helper->startLiveTranscription();
}Cause: No one is speaking or audio not connected
Fix: Ensure audio is connected:
void onSessionJoin() override {
sdk->getAudioHelper()->startAudio(); // Connect audio first
transcription->StartTranscription();
}Cause: Spoken language not set correctly
Fix: Set spoken language:
auto languages = manager->GetAvailableLanguages();
for (auto lang : languages) {
if (wcscmp(lang->getLTTLanguageID(), L"en") == 0) {
manager->SetSpokenLanguage(lang);
break;
}
}