Skip to content

Commit fb603d4

Browse files
committed
feat: Add example for convo AI service
1 parent 90e1a4d commit fb603d4

File tree

4 files changed

+611
-0
lines changed

4 files changed

+611
-0
lines changed

examples/convoai/README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Conversational AI Service
2+
3+
English | [简体中文](./README_ZH.md)
4+
5+
> This is a sample project for the Agora Conversational AI engine, utilizing the Agora Conversational Engine API to implement conversational AI functionalities.
6+
7+
## Prerequisites
8+
9+
Set up environment variables. The basic environment variables include:
10+
11+
```bash
12+
export APP_ID=<Your App ID>
13+
export BASIC_AUTH_USERNAME=<Your Basic Auth Username>
14+
export BASIC_AUTH_PASSWORD=<Your Basic Auth Password>
15+
export CONVOAI_TOKEN=<Your Agent Token>
16+
export CONVOAI_CHANNEL=<Your Channel Name>
17+
export CONVOAI_AGENT_RTC_UID=<Your Agent RTC UID>
18+
```
19+
20+
You can find the relevant parameters in the [Conversational AI Service Documentation](../../services/convoai/README.md).
21+
22+
When choosing different TTS providers, you need to configure additional environment variables. The currently supported TTS providers are:
23+
24+
### bytedance
25+
26+
```bash
27+
export CONVOAI_TTS_BYTEDANCE_TOKEN=<Your tts bytedance token>
28+
export CONVOAI_TTS_BYTEDANCE_APP_ID=<Your tts bytedance app id>
29+
export CONVOAI_TTS_BYTEDANCE_CLUSTER=<Your tts bytedance cluster>
30+
export CONVOAI_TTS_BYTEDANCE_VOICE_TYPE=<Your tts bytedance voice type>
31+
```
32+
33+
### tencent
34+
35+
```bash
36+
export CONVOAI_TTS_TENCENT_APP_ID=<Your tts tencent app id>
37+
export CONVOAI_TTS_TENCENT_SECRET_ID=<Your tts tencent secret id>
38+
export CONVOAI_TTS_TENCENT_SECRET_KEY=<Your tts tencent secret key>
39+
```
40+
41+
### minimax
42+
43+
```bash
44+
export CONVOAI_TTS_MINIMAX_GROUP_ID=<Your tts minimax group id>
45+
export CONVOAI_TTS_MINIMAX_GROUP_KEY=<Your tts minimax group key>
46+
export CONVOAI_TTS_MINIMAX_GROUP_MODEL=<Your tts minimax group model>
47+
```
48+
49+
### microsoft
50+
51+
```bash
52+
export CONVOAI_TTS_MICROSOFT_KEY=<Your tts microsoft key>
53+
export CONVOAI_TTS_MICROSOFT_REGION=<Your tts microsoft region>
54+
export CONVOAI_TTS_MICROSOFT_VOICE_NAME=<Your tts microsoft voice name>
55+
```
56+
57+
### elevenLabs
58+
59+
```bash
60+
export CONVOAI_TTS_ELEVENLABS_API_KEY=<Your tts elevenLabs api key>
61+
export CONVOAI_TTS_ELEVENLABS_MODEL_ID=<Your tts elevenLabs model id>
62+
export CONVOAI_TTS_ELEVENLABS_VOICE_ID=<Your tts elevenLabs voice id>
63+
```
64+
65+
## Execution
66+
67+
Run the sample project with the following command:
68+
69+
```bash
70+
go run main.go -ttsVendor=<ttsVendor> --serviceRegion=<serviceRegion>
71+
```
72+
73+
`ttsVendor` represents different TTS providers. Choose the appropriate TTS provider based on your requirements.
74+
`serviceRegion` represents chosen service region. The currently supported service regions are:
75+
* `ChineseMainland`
76+
* `Global`
77+

examples/convoai/README_ZH.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# 对话式 AI 引擎服务
2+
3+
[English](./README.md) | 简体中文
4+
5+
> 这是一个对话式 AI 引擎的示例项目,利用对话式 AI 引擎 API 实现对话式 AI 功能。
6+
7+
## 前提条件
8+
9+
设置环境变量。基本环境变量包括:
10+
11+
```bash
12+
export APP_ID=<Your App ID>
13+
export BASIC_AUTH_USERNAME=<您的基本认证用户名>
14+
export BASIC_AUTH_PASSWORD=<您的基本认证密码>
15+
export CONVOAI_TOKEN=<您的代理令牌>
16+
export CONVOAI_CHANNEL=<您的频道名称>
17+
export CONVOAI_AGENT_RTC_UID=<您的代理 RTC UID>
18+
```
19+
20+
您可以在 [对话式 AI 服务文档](../../services/convoai/README_ZH.md) 中找到相关参数。
21+
22+
选择不同的 TTS 提供商时,需要配置额外的环境变量。目前支持的 TTS 提供商有:
23+
24+
### bytedance
25+
26+
```bash
27+
export CONVOAI_TTS_BYTEDANCE_TOKEN=<Your tts bytedance token>
28+
export CONVOAI_TTS_BYTEDANCE_APP_ID=<Your tts bytedance app id>
29+
export CONVOAI_TTS_BYTEDANCE_CLUSTER=<Your tts bytedance cluster>
30+
export CONVOAI_TTS_BYTEDANCE_VOICE_TYPE=<Your tts bytedance voice type>
31+
```
32+
33+
### tencent
34+
35+
```bash
36+
export CONVOAI_TTS_TENCENT_APP_ID=<Your tts tencent app id>
37+
export CONVOAI_TTS_TENCENT_SECRET_ID=<Your tts tencent secret id>
38+
export CONVOAI_TTS_TENCENT_SECRET_KEY=<Your tts tencent secret key>
39+
```
40+
41+
### minimax
42+
43+
```bash
44+
export CONVOAI_TTS_MINIMAX_GROUP_ID=<Your tts minimax group id>
45+
export CONVOAI_TTS_MINIMAX_GROUP_KEY=<Your tts minimax group key>
46+
export CONVOAI_TTS_MINIMAX_GROUP_MODEL=<Your tts minimax group model>
47+
```
48+
49+
### microsoft
50+
51+
```bash
52+
export CONVOAI_TTS_MICROSOFT_KEY=<Your tts microsoft key>
53+
export CONVOAI_TTS_MICROSOFT_REGION=<Your tts microsoft region>
54+
export CONVOAI_TTS_MICROSOFT_VOICE_NAME=<Your tts microsoft voice name>
55+
```
56+
57+
### elevenLabs
58+
59+
```bash
60+
export CONVOAI_TTS_ELEVENLABS_API_KEY=<Your tts elevenLabs api key>
61+
export CONVOAI_TTS_ELEVENLABS_MODEL_ID=<Your tts elevenLabs model id>
62+
export CONVOAI_TTS_ELEVENLABS_VOICE_ID=<Your tts elevenLabs voice id>
63+
```
64+
65+
## 执行
66+
67+
使用以下命令运行示例项目:
68+
69+
```bash
70+
go run main.go -ttsVendor=<ttsVendor> --serviceRegion=<serviceRegion>
71+
```
72+
73+
`ttsVendor` 代表不同的 TTS 提供商。根据您的需求选择合适的 TTS 提供商。
74+
`serviceRegion` 代表选择的服务区域。目前支持的服务区域有:
75+
* `ChineseMainland`
76+
* `Global`
77+

examples/convoai/main.go

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package main
2+
3+
import (
4+
"flag"
5+
"log"
6+
"os"
7+
8+
"github.com/AgoraIO-Community/agora-rest-client-go/agora/domain"
9+
"github.com/AgoraIO-Community/agora-rest-client-go/examples/convoai/service"
10+
"github.com/AgoraIO-Community/agora-rest-client-go/services/convoai"
11+
)
12+
13+
var (
14+
appId string
15+
username string
16+
password string
17+
domainArea = domain.CN
18+
)
19+
20+
func main() {
21+
log.SetFlags(log.LstdFlags | log.Lshortfile)
22+
23+
appId = os.Getenv("APP_ID")
24+
if appId == "" {
25+
panic("APP_ID is required")
26+
}
27+
28+
username = os.Getenv("BASIC_AUTH_USERNAME")
29+
if username == "" {
30+
panic("BASIC_AUTH_USERNAME is required")
31+
}
32+
33+
password = os.Getenv("BASIC_AUTH_PASSWORD")
34+
if password == "" {
35+
panic("BASIC_AUTH_PASSWORD is required")
36+
}
37+
38+
ttsVendor := flag.String("ttsVendor", "", "tts vendor, e.g. bytedance,microsoft,tencent,minimax,elevenLabs")
39+
serviceRegion := flag.Int("serviceRegion", 0, "service region, e.g. 1: ChineseMainland, 2: Global")
40+
flag.Parse()
41+
42+
if *serviceRegion == 0 {
43+
log.Fatalln("serviceRegion should be specified")
44+
}
45+
46+
s := service.New(domainArea, appId, convoai.ServiceRegion(*serviceRegion))
47+
s.SetCredential(username, password)
48+
49+
switch *ttsVendor {
50+
case "bytedance":
51+
if *serviceRegion == 2 {
52+
log.Fatalln("Bytedance TTS is not supported in Global service region")
53+
}
54+
55+
s.RunWithBytedanceTTS()
56+
case "microsoft":
57+
if *serviceRegion == 2 {
58+
log.Fatalln("Microsoft TTS is not supported in ChineseMainland service region")
59+
}
60+
61+
s.RunWithMicrosoftTTS()
62+
case "tencent":
63+
if *serviceRegion == 2 {
64+
log.Fatalln("Tencent TTS is not supported in Global service region")
65+
}
66+
67+
s.RunWithTencentTTS()
68+
case "minimax":
69+
if *serviceRegion == 2 {
70+
log.Fatalln("Minimax TTS is not supported in Global service region")
71+
}
72+
73+
s.RunWithMinimaxTTS()
74+
case "elevenLabs":
75+
if *serviceRegion == 2 {
76+
log.Fatalln("ElevenLabs TTS is not supported in ChineseMainland service region")
77+
}
78+
79+
s.RunWithElevenLabsTTS()
80+
default:
81+
log.Fatalln("Invalid tts vendor")
82+
}
83+
}

0 commit comments

Comments
 (0)