voice changer plugin for TRTC Web SDK
npm install rtc-voice-changerThe RTCVoiceChanger plugin can be used in conjunction with the TRTC Web SDK to change the voice on TRTC calls.
  
English | 简体中文
Supported browsers: Chrome 66+, Edge 79+, Safari 14.1+, Firefox 76+.
For better use of rtc-voice-changer, it is recommended that you use the latest version of Chrome.
shell
npm install rtc-voice-changer
`Feature Description
$3
`javascript
import RTCVoiceChanger from 'rtc-voice-changer';
const voiceChanger = new RTCVoiceChanger();
`$3
A processor can only process one stream.
`javascript
let localStream = TRTC.createStream({ audio: true, video: true });
await localStream.initialize();
const processor = voiceChanger.createProcessor({ userId, sdkAppId, userSig });// 1-Brat 2-Loli 3-Uncle 4-Heavy Metal 5-Cold 6-Foreign Accent 7-Beast 8-Fat Otaku 9-Strong Current 10-Heavy Machinery 11-Ethereal
await processor.process(localStream, 1);
// Switch effects midway
processor.setEffect(3);
`$3
`javascript
await client.leave();
voiceChangerProcessor.destroy();
`API
$3
Create a plugin instance`javascript
const rtcVoiceChanger = new RTCVoiceChanger();
`#### createProcessor(params)
Create a Processor instance
`javascript
const voiceChangerProcessor = await rtcVoiceChanger.createProcessor({
sdkAppId,
userId,
userSig
});
`
Params:| Name | Type | Description |
| -------- | -------- | ------------------------------------------------------------ |
| sdkAppId |
number | sdkAppId
Get the sdkAppId information in Application Information after creating a new application by clicking Application Management > Create Application in the Real-Time Audio and Video Console. |
| userId | string | User ID
It is recommended to limit the length to 32 bytes, and only allow uppercase and lowercase English letters (a-zA-Z), numbers (0-9), underscores, and hyphens. |
| userSig | string | UserSig signature
Refer to UserSig Related for how to calculate userSig. |$3
#### process(localStream, voiceType)
Add noise reduction effect to the audio of the local stream.
Params:
| Name | Type | Description |
|-------------|---------------|----------------------------------------------------------------|
| localStream |
LocalStream | Local stream. |
| voiceType | number | 1-Brat 2-Loli 3-Uncle 4-Heavy Metal 5-Cold 6-Foreign Accent 7-Beast 8-Fat Otaku 9-Strong Current 10-Heavy Machinery 11-Ethereal. |
`javascript
await voiceChangerProcessor.process(localStream, 1);
`#### setEffect(type)
Switch effects.
| Name | Type | Description |
|-------------|---------------|----------------------------------------------------------------|
| voiceType |
number | 1-Brat 2-Loli 3-Uncle 4-Heavy Metal 5-Cold 6-Foreign Accent 7-Beast 8-Fat Otaku 9-Strong Current 10-Heavy Machinery 11-Ethereal. |`javascript
await voiceChangerProcessor.setEffect(2);
`
#### close()Turn off the voice changing effect.
`javascript
voiceChangerProcessor.close();
`#### destroy()
Destroy the processor and release resources, ending the processor's lifecycle.
`javascript
voiceChangerProcessor.destroy();
``