Skip to content

highras/rtvt-agora-marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 

Repository files navigation

LiveData RTVT

This guide is provided by LiveData. Agora is planning a documentation upgrade program for all extensions on the marketplace. Please stay tuned.

LiveData RTVT extension allows you to embed real-time voice transcription and translation into your mobile application providing automated speech recognition(ASR) without any upfront data training requirements.You can find the integration examples below.

Understand the tech

The LiveData RTVT extension encapsulates the core APIs of the LiveData RTVT SDK. By calling the setExtensionProperty or setExtensionPropertyWithVendor method of the Agora Video SDK v4.x and passing in the corresponding key and value, you can quickly integrate capabilities of LiveData RTVT. For details, see the key-value overview.

Prerequisites

The development environment has to meet the following requirements:

  • Android
    • Android Studio 4.1 or later
    • A physical device (not an emulator) running Android 5.0 or later
  • iOS
    • Xcode 9.0 or later.
    • A physical device (not an emulator) running iOS 11.0 or later.

Project Setup

The LiveData RTVT extension works together with the Video SDK v4.x. Refer to the following doc to integrate the SDK and start a basic voice call:

To receive a appKey and a appSecret from LiveData

  • please buy and activate the extension project on Agora Console, then click View in the Secret column.
  • or contact us via Agora.

Integrate the extension

Android

  1. Download the Android package of LiveData RTVT from the Extensions Marketplace.
  2. Unzip the package, and save all .aar files to the /app/libs path of your project folder.
  3. In the app/build.gradle file, add the following line in dependencies:
implementation fileTree(dir: "libs", include: ["*.jar", "*.aar"])

iOS

  1. Download the iOS package of LiveData RTVT from the Extensions Marketplace.
  2. Unzip the package, and save all .framework files to the <ProjectName> path.
  3. Ensure that you select Embed & Sign instead of Embed.

You can save .framework files under your project folder, as follows:

.
├── <ProjectName>
├── <ProjectName>.xcodeproj

Call Sequence

This section describes the call sequence you implement to use LiveData RTVT features in your app.

1. Enable the extension

Android

When you initialize AgoraRtcEngine :

  • first call addExtension to load the extension
  • then call enableExtension to enable the extension
RtcEngineConfig config = new RtcEngineConfig();
config.addExtension("agora-iLiveData-filter");
engine = RtcEngine.create(config);
engine.enableExtension("iLiveData", "RTVT", true);

iOS

When you initialize AgoraRtcEngine, call enableExtensionWithVendor to enable the extension.

AgoraRtcEngineConfig *config = [AgoraRtcEngineConfig new];

// set config.eventDelegate = self to accept the `onEvent` callback
// enable RTVT extension
[_agoraKit enableExtensionWithVendor:[iLiveDataSimpleFilterManager companyName]
                          extension:[iLiveDataSimpleFilterManager plugName]
                            enabled:YES];

2. Start using the extension

Android

When you are ready to start using RTVT, call setExtensionProperty and pass in the corresponding keys and values:

  • set key asstartAudioTranslation
  • set value as appkey, appsecret, srclang, dstLang in JSON
JSONObject jsonObject = new JSONObject();
jsonObject.put("appKey", "appKey");
jsonObject.put("appSecret", "appSecrect");
jsonObject.put("srclang", "zh");
jsonObject.put("dstLang", "en");

engine.setExtensionProperty(EXTENSION_VENDOR_NAME, EXTENSION_AUDIO_FILTER_VOLUME, "startAudioTranslation", jsonObject.toString());

iOS

When you are ready to start using RTVT, call setExtensionPropertyWithVendor and pass in the corresponding keys and values:

  • set key asstartAudioTranslation
  • set value as appkey, appsecret,srclang dstLang in JSON
NSDictionary * translateDic = @{
                                @"appKey":@"appKey",
                                @"appSecret":@"appSecret",
                                @"srcLanguage":@"zh",
                                @"destLanguage":@"en"
                              };

NSData * translateDicJsonData = [NSJSONSerialization dataWithJSONObject:translateDic options:NSJSONWritingPrettyPrinted error:nil];
NSString * translateDicJsonString = [[NSString alloc] initWithData:translateDicJsonData encoding:NSUTF8StringEncoding];

[_agoraKit setExtensionPropertyWithVendor:[iLiveDataSimpleFilterManager companyName]
                                extension:[iLiveDataSimpleFilterManager rtvt_plugName])
                                      key:@"startAudioTranslation"
                                    value:translateDicJsonString];

3. Stop using the extension

Android

When stop using RTVT, call setExtensionProperty and pass in the corresponding keys and values:

  • set key ascloseAudioTranslation
  • set value as end
engine.setExtensionProperty(EXTENSION_VENDOR_NAME, EXTENSION_AUDIO_FILTER_VOLUME, "closeAudioTranslation", "end");

iOS

When stop using RTVT, call setExtensionPropertyWithVendor and pass in the corresponding keys and values:

  • set key ascloseAudioTranslation
  • set value as end
[_agoraKit setExtensionPropertyWithVendor:[iLiveDataSimpleFilterManager companyName]
                                extension:[iLiveDataSimpleFilterManager rtvt_plugName]
                                      key:"closeAudioTranslation"
                                    value:"end"];

4. Result callback

LiveData RTVT extension provides result of voice transcription and translation, you can receive all return of results or either of them, using onEvent callback of the Agora SDK.

Android

After enable LiveData RTVT extension, you can receive the results of voice transcription and translation via onEvent callback. The description of onEvent callback keys can be seen below.

@Override
public void onEvent(String vendor, String extension, String key, String value) {
      key: "recognizeResult"  "translateResult"
      value:
        {
            ""result", 
            "startTs", 
            "endTs",
        }
}

iOS

After enable LiveData RTVT extension, you can receive the results of voice transcription and translation via onEvent callback. The description of onEvent callback keys can be seen below.

-(void)onEvent:(NSString *)provider extension:(NSString *)extension key:(NSString *)key value:(NSString *)value{

       provider:"iLiveData"
      extension:"RTVT"
            key: "recognizeResult"  "translateResult"
          value:
              {
                ""result", 
                "startTs", 
                "endTs",
              }
}

Sample Project

The complete sample code and project is provided on GitHub:

Platform Language Sample Project
Android Java Sample Project
iOS Objective-C Sample Project

Run the project

Android

  1. git clone:
git clone https://github.com/highras/rtvt-agora-marketplace.git
  1. Open the Sample project in Android Studio.
  2. Gradle sync with the project.
  3. Open app/src/main/res/values/string_configs.xml file:
    • change agora_app_id and agora_access_token to your own Agora project information.
    • change livedata_translate_pid and livedata_translate_key to your own LiveData RTVT extension information。
  4. Using a physical Android device (not an emulator) to run the project.

iOS

  1. git clone:
git clone https://github.com/highras/rtvt-agora-marketplace.git
  1. Open the project in Xcode. Access to the iOS/SW_Test path, and run the CocoaPods command as below:
pod install
  1. Open the sample project SW_Test.xcworkspace in Xcode.
  2. Open iOS/SW_Test/SW_Test/ViewController.mm file:
    • Fill in you own project information appId and Token from Agora console.
    • Fill in your own LiveData RTVT extension information appKeyRTVT and appSecretRTVT from Agora console。
  3. Using a physical iOS device (not an emulator) to run the project.

Result

After running the project successfully, LiveData RTVT sample project will be installed on you Android or iOS device.

  1. Start the sample, fill in the channel number in the input box and click Join. The button Join will be change to Leave after join the channel successfully.
  2. Click the button start translation, speak to the device microphone, and you will see the real-time transcription and translation on the screen.
  3. Click the button stop translation to stop transcription and translation.
  4. Click the button stopto stop running LiveData RTVT sample project.

API reference

This section lists the APIs related to using extensions with the Agora SDK.

Android

iOS

Key description

To implement the LiveData RTVT extension in app, you need to pass in the corresponding key-value pair。

setExtensionProperty or setExtensionPropertyWithVendor

When calling setExtensionProperty or setExtensionPropertyWithVendor, you can pass keys:

Key Description
startAudioTranslation start real-time voice transcription and translation
closeAudioTranslation stop real-time voice transcription and translation

onEvent

The Agora SDK onEvent contain keys:

Key Description
recognizeResult result of real-time voice transcription
translateResult result of real-time voice translation
start error message when calling startAudioTranslation

Key-value description

startAudioTranslation

Value Description
appKey buy and activate the extension project on Agora Console, then click View in the Secret column
appSecret buy and activate the extension project on Agora Console, then click View in the Secret column.
srcLanguage source language, see language supported list
destLanguage destination language, see language supported list

closeAudioTranslation

Value Description
end stop real-time voice transcription and translation

recognizeResult

Value Description
{"result", "startTs", "endTs"} result of real-time voice transcription

translateResult

Value Description
{"result", "startTs", "endTs"} result of real-time voice translation

start

Value Description
start error message when calling startAudioTranslation

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published