Parse transcription data
Agora utilizes Protocol Buffers (protobuf) to serialize transcription data. Developed by Google, Protobuf is a language-neutral, platform-independent mechanism for serializing structured data. It allows for the efficient and consistent handling of data across different platforms by generating source code in multiple programming languages. For more information about Google protocol buffers, see protobuf.dev.
Prerequisites
To follow this procedure:
-
Have a valid Agora Account.
-
Have a valid Agora project with an app ID and a temporary token or a token server. For details, see Agora account management.
-
Have a computer with access to the internet. If your network has a firewall, follow the steps in Firewall requirements.
-
Join an RTC channel as a host and start streaming.
- Make sure Real-Time STT is enabled for your app.
- Install the Protobuf package to generate code classes for displaying transcription text.
Use Protobuf to parse transcription data
Protobuf enables you to generate source code in your preferred coding language, based on the structure specified in the .proto file. Agora provides the following Protobuf template for parsing data:
To parse and display the text in your client:
-
Copy the Protobuf template to a local
.protofile. -
In your file, edit the following properties to match your project:
package: The source code package namespace.option: The desired language options.
-
To generate a Protobuf class, run the
protocprotocol compiler on your.protofile to generate the code that you use to work with the transcription message type.Invoke the
protoccompiler as follows:Agora also provides Protobuf sample code to parse and display transcription text. To obtain the sample code, contact support@agora.io
-
Use the Protobuf class to read transcription text.
When transcription text is available, your Video SDK app receives the
onStreamMessagecallback. Use the generated Protobuf class in you app to read the byte data returned by the callback. Refer to theonStreamMessagecallback in the API reference for your platform.
Demo project
Check out the demo project on Github.