Skip to content

Commit

Permalink
Merge branch 'staging' of https://github.com/AgoraIO/Doc-Source-Private
Browse files Browse the repository at this point in the history
… into staging
  • Loading branch information
atovpeko committed Dec 12, 2023
2 parents ce045e0 + 3d97226 commit e850b8c
Show file tree
Hide file tree
Showing 11 changed files with 376 additions and 2 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions extensions-marketplace/develop/integrate/dubbing-voice-changer.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
title: "Dabi AI Dubbing Voice Changer"
sidebar_position: 3
type: docs
description: >
Dabi AI voice changing plug-in is an encapsulation of the core API of real-time AI voice conversion.
---
export const toc = [{}];

import DubbingVoiceChanger from '@docs/shared/extensions-marketplace/dubbing-voice-changer/index.mdx';

<DubbingVoiceChanger />
56 changes: 56 additions & 0 deletions shared/extensions-marketplace/dubbing-voice-changer/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import ProjectImplementation from '@docs/shared/extensions-marketplace/dubbing-voice-changer/project-implementation/index.mdx';
import Reference from '@docs/shared/extensions-marketplace/dubbing-voice-changer/reference/index.mdx';

<Vg k="RTEE_DUB" /> extension enables you to change the audio timbre.

<PlatformWrapper notAllowed="android, ios">
**This extension is not yet available for <Vpl k="NAME" />.**
</PlatformWrapper>

<PlatformWrapper notAllowed="web, macos, windows, flutter, react-native">
This page shows you how to integrate the <Vg k="RTEE_DUB" /> extension in your app.

## Understand the tech

<PlatformWrapper platform="android">
Using the <Link to="{{Global.API_REF_ANDROID_ROOT}}/class_irtcengine.html#api_irtcengine_setextensionproperty">setExtensionProperty</Link> method provided in <Vg k="COMPANY" /> SDK v<Vg k="VSDK_RELEASE_API" /> and passing in the specified `key` and `value` parameters, you can quickly integrate real-time AI voice conversion ability into your <Vpl k="CLIENT" />.

The `key` parameter you specify in the `setExtensionProperty` method corresponds to the name of the API, and the `value` parameter wraps some or all of the parameters of the API in JSON format. By passing in the specified `key` and `value` parameters, you can call the corresponding API to realize the functions related to real-time AI sound conversion.
</PlatformWrapper>

<PlatformWrapper platform="ios">
Using the <Link to="{{Global.API_REF_IOS_ROOT}}/class_irtcengine.html#api_irtcengine_setextensionproperty">setExtensionPropertyWithVendor</Link> method provided in <Vg k="COMPANY" /> SDK v<Vg k="VSDK_RELEASE_API" /> and passing in the specified `key` and `value` parameters, you can quickly integrate real-time AI voice conversion ability into your <Vpl k="CLIENT" />.

The `key` parameter you specify in the `setExtensionPropertyWithVendor` method corresponds to the name of the API, and the `value` parameter wraps some or all of the parameters of the API in JSON format. By passing in the specified `key` and `value` parameters, you can call the corresponding API to realize the functions related to real-time AI sound conversion.
</PlatformWrapper>

## Prerequisites

Ensure that your development environment meets the following requirements:

<PlatformWrapper platform="android">
- Android Studio 4.1 or later.
- A physical device (not an emulator) running Android 5.0 or later.
</PlatformWrapper>

<PlatformWrapper platform="ios">
- Xcode 9.0 or later.
- A physical device (not an emulator) running iOS 8.0 or later.
</PlatformWrapper>
- <Vg k="RTEE_DUB" /> is used with <Vg k="COMPANY" /> <Vg k="ASDK" /> v<Vg k="VSDK_RELEASE_API" />.

Refer to the [SDK quickstart](/voice-calling/get-started/get-started-sdk) to integrate <Vg k="ASDK" /> v<Vg k="VSDK_RELEASE_API" /> and implement basic voice calling.

## Integrate the extension

This section shows you how to integrate the <Vg k="RTEE_DUB" /> extension, and call the core API to implement the voice changing function.

<ProjectImplementation />

## Reference

This section contains information that completes the information in this page, or points you to documentation that explains other aspects to this product.

<Reference />

</PlatformWrapper>
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<PlatformWrapper platform="android">

1. **Integrate the <Vg k="RTEE_DUB" /> extension**

To integrate the extension in your project:

1. Enter the [Agora console > Cloud Market](https://console.agora.io/marketplace/list/all) page and download the <Vpl k="NAME" /> **<Vg k="RTEE_DUB" />** extension package. After unzipping, save all `.aar` files to the project folder `/app/libs`.
1. Get the following resource files and save them in the same directory of the project folder. For example, a new `vc_model` directory:
- License file and tone files: Contact <Vg k="COMPANY" /> to obtain these files. The suffix of the tone file is `.dat`, and the tone file is issued according to the license.
- Model file: Download the required resources.
![Resource Files](/images/extensions-marketplace/resource-files.png)
1. Open the `app/build.gradle` file and add the following lines under `dependencies`:

```java
implementation fileTree(dir: "libs", include: ["*.jar", "*.aar"])
```

1. **Enable the plugin**

After creating and initializing `RtcEngine`, call `enableExtension` to enable the plug-in, before you call other APIs such as `enableVideo` and `joinChannel`.

```kotlin
// Declare parameters
private val EXTENSION_NAME = "dubbing_vc"
private val EXTENSION_VENDOR_NAME = "Dubbing"
private val EXTENSION_AUDIO_FILTER = "DubbingVC"

private val changeSpeaker_ = "changeSpeaker"
private val startRealTimeTranscribe_ = "startRealTimeTranscribe"
private val stopRealTimeTranscribe_ = "stopRealTimeTranscribe"
private val getSpeakersInfo_ = "getSpeakersInfo"

val config = RtcEngineConfig()
config.mContext = baseContext
config.mAppId = appId
config.mEventHandler = mRtcEventHandler
// Load plugin
config.addExtension(EXTENSION_NAME)
config.mExtensionObserver = extensionObserver
// Create and initialize RtcEngine
mRtcEngine = RtcEngine.create(config)
mRtcEngine.enableAudio()
// Enable plugin
mRtcEngine.enableExtension(EXTENSION_VENDOR_NAME, EXTENSION_AUDIO_FILTER, enable)
```

1. **Set the resource file path**

When you download and integrate the plug-in, the license, sound, and model files are saved to the specified directory. In this step, you specify the path where these resource files are located.

```kotlin
val modelPath: String = "${context.filesDir}${File.separator}vc_model"
```

1. **Get the tone list**

After receiving the `onExtensionStarted` callback from <Vg k="COMPANY" /> SDK, call `getExtensionProperty` passing in the `getSpeakersInfo` key to get the timbre list:

```kotlin
val speakerList = mRtcEngine.getExtensionProperty(
EXTENSION_VENDOR_NAME,
EXTENSION_AUDIO_FILTER,
getSpeakersInfo_
)
// Convert JSON to array
val arr = JSONArray(speakerList)
```

The timbre list is returned as JSON data that you parse yourself.

1. **Start changing**

Call `setExtensionProperty` and pass in the corresponding `key` and `value`:

```kotlin
mRtcEngine.setExtensionProperty(
EXTENSION_VENDOR_NAME,
EXTENSION_AUDIO_FILTER,
startRealTimeTranscribe_,
"true"
)
```

1. **Select timbre**

Pass in the timbre ID from the obtained timbre list to set the corresponding timbre:

```kotlin
mRtcEngine.setExtensionProperty(
EXTENSION_VENDOR_NAME,
EXTENSION_AUDIO_FILTER,
changeSpeaker_,
id
)
```

1. **Stop changing**

Call the API to stop the voice changer:

```kotlin
mRtcEngine.setExtensionProperty(
EXTENSION_VENDOR_NAME,
EXTENSION_AUDIO_FILTER,
stopRealTimeTranscribe_,
"true"
)
```

1. **Release resources**

Close the plug-in and release the resources used by the plug-in:

```kotlin
mRtcEngine.enableExtension(EXTENSION_VENDOR_NAME, EXTENSION_AUDIO_FILTER, false)
```

</PlatformWrapper>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Android from './android.mdx';
import Ios from './ios.mdx';

<Android />
<Ios />
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<PlatformWrapper platform="ios">

1. **Integrate the <Vg k="RTEE_DUB" /> extension**

To integrate the extension in your project:

1. Enter the [Agora console > Cloud Market](https://console.agora.io/marketplace/list/all) page and download the <Vpl k="NAME" /> plug-in package for **<Vg k="RTEE" />** plug-in.
1. Unzip the folder, import all `.framework` files into the project, and modify `Embed` to `Embed & Sign`.
1. Get the following resource files and save them in the same directory of the project folder (For example, Resource path):
- License file and tone files: Contact <Vg k="COMPANY" /> to obtain these files. The suffix of the tone file is named `.dat`, and the tone file is issued according to the license.
- Model file: Download the required resources.
![Resource Files](/images/extensions-marketplace/resource-files.png)
1. Import the `libc++` system library and third-party dynamic libraries into the project `MJExtension`.

1. **Enable the plugin**

After creating and initializing `RtcEngine`, call `enableExtensionWithVendor` to enable the plug-in, before you call other APIs such as `enableVideo`, and `joinChannelByToken`

```objective-c
AgoraRtcEngineConfig *cfg = [[AgoraRtcEngineConfig alloc] init];
cfg.appId = appId;
cfg.eventDelegate = self;
cfg.channelProfile = AgoraChannelProfileLiveBroadcasting;
cfg.audioScenario = AgoraAudioScenarioGameStreaming;
self.agoraKit = [AgoraRtcEngineKit sharedEngineWithConfig:cfg delegate:self];
[self.agoraKit setClientRole:AgoraClientRoleBroadcaster];

[self.agoraKit enableExtensionWithVendor:[EngineFilterManager vendorName] extension:@"RealTimeTranscribe" enabled:YES];
```

1. **Set the resource file path**

When you download and integrate the plug-in, the license, sound, and model files are saved to the specified directory. In this step, you specify the path where these resource files are located.

```objective-c
NSString *sourcePath = [[NSBundle mainBundle] resourcePath];
[self.agoraKit setExtensionPropertyWithVendor:[EngineFilterManager vendorName] extension:@"RealTimeTranscribe" key:@"setResourcesFilePath" value:sourcePath];
```

1. **Get the tone list**

After receiving the `onExtensionStarted` callback from <Vg k="COMPANY" /> SDK, call `getExtensionPropertyWithVendor` passing in the `getSpeakersInfo` key to get the timbre list:

```objective-c
NSString *voices = [self.agoraKit getExtensionPropertyWithVendor:[EngineFilterManager vendorName] extension:@"RealTimeTranscribe" key:@"getSpeakersInfo"];
// Convert JSON to array
NSData *nsData = [voices dataUsingEncoding:NSUTF8StringEncoding];
_speakerArray = [NSJSONSerialization JSONObjectWithData:nsData options:kNilOptions error:nil];
```

The timbre list is returned as JSON data that you parse yourself.

1. **Start changing**

Call `setExtensionPropertyWithVendor` and pass in the corresponding `key` and `value`:

```objective-c
[self.agoraKit setExtensionPropertyWithVendor:[EngineFilterManager vendorName] extension:@"RealTimeTranscribe" key:@"startRealTimeTranscribe" value:@"startRealTimeTranscribe"];
```

1. **Select timbre**

Pass in the timbre ID from the obtained timbre list to set the corresponding timbre:

```objective-c
[self.agoraKit setExtensionPropertyWithVendor:[EngineFilterManager vendorName] extension:@"RealTimeTranscribe" key:@"changeSpeaker" value:@“”];
```

1. **Stop changing**

Call the API to stop the voice changer:

```objective-c
[self.agoraKit setExtensionPropertyWithVendor:[EngineFilterManager vendorName] extension:@"RealTimeTranscribe" key:@"stopRealTimeTranscribe" value:@"stopRealTimeTranscribe"];
```

1. **Release resources**

Close the plug-in and release the resources used by the plug-in:

```objective-c
[self.agoraKit enableExtensionWithVendor:[EngineFilterManager vendorName] extension:@"RealTimeTranscribe" enabled:NO];
```

</PlatformWrapper>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<PlatformWrapper platform="android">

### Sample project

The <Vg k="RTEE_DUB" /> extension provides a [GitHub sample project](https://github.com/Dubbing-AI-Voice-Changer/DubbingAgoraDemo/tree/main/Android) for testing. To clone and run the project:

1. Clone the repository

```sh
git clone https://github.com/Dubbing-AI-Voice-Changer/DubbingAgoraDemo.git
```

2. Refer to the `README.md` file in the repository to run the demo.

### API reference

- <Link to="{{Global.API_REF_ANDROID_ROOT}}/rtc_api_data_type.html#api_irtcengine_addextension">addExtension</Link> in the `RtcEngineConfig` class
- <Link to="{{Global.API_REF_ANDROID_ROOT}}/class_irtcengine.html#api_irtcengine_enableextension">enableExtension</Link> in the `RtcEngine` class
- <Link to="{{Global.API_REF_ANDROID_ROOT}}/class_irtcengine.html#api_irtcengine_setextensionproperty">setExtensionProperty</Link> in the `RtcEngine` class

</PlatformWrapper>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Android from './android.mdx';
import Ios from './ios.mdx';

<Android />
<Ios />
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<PlatformWrapper platform="ios">

### Sample project

The <Vg k="RTEE_DUB" /> extension provides a [GitHub sample project](https://github.com/Dubbing-AI-Voice-Changer/DubbingAgoraDemo/tree/main/iOS) for testing. To clone and run the project:

1. Clone the repository

```sh
git clone https://github.com/Dubbing-AI-Voice-Changer/DubbingAgoraDemo.git
```

2. Refer to the `README.md` file in the repository to run the demo.


### API reference

- <Link to="{{Global.API_REF_IOS_ROOT}}/class_irtcengine.html#api_irtcengine_enableextension">enableExtensionWithVendor</Link> in the `AgoraRtcEngineKit` class
- <Link to="{{Global.API_REF_IOS_ROOT}}/class_irtcengine.html#api_irtcengine_setextensionproperty">setExtensionPropertyWithVendor</Link> in the `AgoraRtcEngineKit` class

</PlatformWrapper>
1 change: 1 addition & 0 deletions shared/variables/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ export const RTEE_FU = 'FaceUnity';
export const RTEE_AF = 'ActiveFence';
export const RTEE_AF_D = `ActiveOS`;
export const RTEE_HT3D = `HTEffect 3D Avatar`
export const RTEE_DUB = `Dabi AI Dubbing Voice Changer`
export const AA = `${COMPANY} Analytics`;
export const AA_DI = `Data Insights`;
export const AA_DIP = `Data Insights Plus`;
Expand Down
Loading

0 comments on commit e850b8c

Please sign in to comment.