Skip to content

Transcribe streaming audio ​

1. Introduction ​

A real-time speech recognition API that converts voice data spoken by users into text in real-time. Through this API, text obtained from voice data can be used to transmit broadcast subtitles, video conference subtitles, etc.

Key features ​

  • Real-time speech recognition: Converts audio streams into text in real-time
  • Multilingual support: Multilingual speech recognition
  • High Accuracy: State-of-the-art speech recognition technology

WARNING

⚠ Songs or audio with loud background music are not supported.

Use Cases ​

The real-time speech recognition API enables the conversion of speech data into text in real-time. This can greatly enhance the user experience by developing the following real-time speech-based applications or implementing automatic speech-to-text conversion services.

  • Customer feedback analysis: Automatically record real-time conversations in call centers or customer service centers and convert them to text to improve the quality of consultations and manage call records efficiently.
  • Record meeting: Avoid manually writing meetingminutes by recording and sharing meeting content in real time. Content can be easily searched and referenced immediatelyafter a meeting.
  • Create real-time subtitles: Add live subtitles to online lectures, live-stream videos, and more to make content more accessible to users.
  • Medical records: Translate a medical professional's voice into text and enter it into the Electronic Medical Records (EMR) system.
  • Control smart home devices: Translate voice into text to process commands for smart home devices.

2. Example ​

The following example uses the streaming STT API.

You can check the token issuance and real-time audio transmission methods in Python.

1) Python Example ​

Python code

text
# This code does not work until the requests, requests-sse package is installed. <CopyButton /><EmailFormButton />
import base64
import concurrent.futures
import json
import requests
from requests_sse import EventSource, InvalidStatusCodeError, InvalidContentTypeError

HOST = 'https://apis.daglo.ai'
API_TOKEN = '<API_TOKEN>'

def get_session_token():
    headers = {'Authorization': f'Bearer {API_TOKEN}'}
    return requests.get(HOST + "/stt/v1/stream/sessionTokens", headers=headers).json()


def send_audio_stream(audio_stream: bytes, sid: str, s_token: str):
    headers = {'Authorization': f'Bearer {s_token}', 'Content-Type': 'application/json'}
    audio_str = base64.b64encode(audio_stream).decode('utf-8')
    data = { 'sessionId': sid, 'channel': 0, 'file': audio_str }
    res = requests.post(HOST + "/stt/v1/stream/recognize", headers=headers, json=data)


def get_audio_stream(sid: str, s_token: str):
    headers = { 'Authorization': f'Bearer {s_token}' }
    with EventSource(HOST + f"/stt/v1/stream/sse/{sid}", timeout=30, headers=headers) as event_source:
        try:
            for event in event_source:
                print(json.loads(event.data))
        except InvalidStatusCodeError:
            pass
        except InvalidContentTypeError:
            pass
        except requests.RequestException:
            pass


if __name__ == '__main__':
    # 1. Prepare Audio Stream.
    sample_audio_stream = requests.get('https://storage.googleapis.com/bkt-actionpower-examples/audio/actionpower_hello.wav').content

    # 2. Acquire Session Token.
    res = get_session_token()
    sid = res['sessionId']
    s_token = res['sessionToken']

    with concurrent.futures.ThreadPoolExecutor(max_workers=1) as executor:
        # 3. Send the audio stream to POST Endpoint.
        future = executor.submit(send_audio_stream, sample_audio_stream, sid, s_token)

        # 4. At the same time, real-time STT results are received via SSE.
        get_audio_stream(sid, s_token)

Print Output

text
{'sessionId': '9070fe6d-c34e-4d45-8e68-11d9f944711', 'channel': 0, 'timestamp': 1724129309929, 'startTime': 1724129309929, 'sttResult': {'transcript': '안녕하세요. 액션파워입니다. 음성 인식의 선두 주자 액션파워의 기술을', 'isFinal': False}

3. Instructions ​

1) Getting an API Key ​

  • Create an account in the API console.
  • Go to the token menu and issue a new token.
  • Copy the issued token information and use it as an authentication token when requested.

2) Sending a request ​

For more API information, please refer to the API Reference and the Real-Time Speech Transcription.

a. Getting a session token

shell
GET https://apis.daglo.ai/stt/v1/stream/sessionTokens

b. Transmitting real-time audio

shell
POST https://apis.daglo.ai/stt/v1/stream/recognize

c. Refresing session token

shell
GET https://apis.daglo.ai/stt/v1/stream/refreshSessionTokens

3) Getting a response ​

a. Get a real-time text stream

shell
GET https://apis.daglo.ai/stt/v1/stream/sse/{sid}

Update history

  • 20240902 ver1.0 API document has been created.