test
This commit is contained in:
@@ -1,5 +1 @@
|
||||
# Vue 3 + Vite
|
||||
|
||||
This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
|
||||
|
||||
Learn more about IDE Support for Vue in the [Vue Docs Scaling up Guide](https://vuejs.org/guide/scaling-up/tooling.html#ide-support).
|
||||
npm run dev
|
||||
@@ -1,43 +0,0 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
|
||||
defineProps({
|
||||
msg: String,
|
||||
})
|
||||
|
||||
const count = ref(0)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<h1>{{ msg }}</h1>
|
||||
|
||||
<div class="card">
|
||||
<button type="button" @click="count++">count is {{ count }}</button>
|
||||
<p>
|
||||
Edit
|
||||
<code>components/HelloWorld.vue</code> to test HMR
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
Check out
|
||||
<a href="https://vuejs.org/guide/quick-start.html#local" target="_blank"
|
||||
>create-vue</a
|
||||
>, the official Vue + Vite starter
|
||||
</p>
|
||||
<p>
|
||||
Learn more about IDE Support for Vue in the
|
||||
<a
|
||||
href="https://vuejs.org/guide/scaling-up/tooling.html#ide-support"
|
||||
target="_blank"
|
||||
>Vue Docs Scaling up Guide</a
|
||||
>.
|
||||
</p>
|
||||
<p class="read-the-docs">Click on the Vite and Vue logos to learn more</p>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.read-the-docs {
|
||||
color: #888;
|
||||
}
|
||||
</style>
|
||||
@@ -11,8 +11,8 @@ class AgoraService {
|
||||
this.vadEnabled = true;
|
||||
// 加入同一RTC频道
|
||||
this.appid = '01a1debc964a4c6a8df1de2a6ce7aa4d';
|
||||
this.token = '007eJxTYEibc7f9w4Ebac5HtT9ej/CL7KzPrGb+GZmn6/G+kLVp8XsFBgPDRMOU1KRkSzOTRJNks0SLlDQg3yjRLDnVPDHRJGV67630hkBGhhvth1kZGSAQxBdhSM7PK0vMBJLF+Tmp8YZGRmZGJgwMAIF3KEg=';
|
||||
this.channel = 'convaiconsole_122624';
|
||||
this.token = '007eJxTYChiW7ib6cSzPW7fP2xqFVvPqf854sNXniin39cd3pu931SlwGBgmGiYkpqUbGlmkmiSbJZokZIG5BslmiWnmicmmqRcenA7vSGQkaFhbQArIwMEgvgiDMn5eWWJmUCyOD8nNd7QwtDAxJyBAQDAkSkW';
|
||||
this.channel = 'convaiconsole_181047';
|
||||
|
||||
// VAD参数调整,检测语音段落
|
||||
this.vadParams = {
|
||||
@@ -46,7 +46,12 @@ class AgoraService {
|
||||
this.client.on('user-published', async (user, mediaType) => {
|
||||
await this.client.subscribe(user, mediaType);
|
||||
if (mediaType === 'audio') {
|
||||
user.audioTrack.play();
|
||||
// 确保不播放本地用户的音频(避免回声)
|
||||
if (user.uid !== this.uid) {
|
||||
user.audioTrack.play();
|
||||
} else {
|
||||
console.log("Prevented local audio playback");
|
||||
}
|
||||
this.remoteUsers[user.uid] = user;
|
||||
}
|
||||
});
|
||||
@@ -86,7 +91,6 @@ class AgoraService {
|
||||
try {
|
||||
// Join the channel
|
||||
this.uid = await this.client.join(this.appid, this.channel, this.token, uid);
|
||||
console.log("successful! this.uid is ", this.uid);
|
||||
|
||||
this.isJoined = true;
|
||||
|
||||
@@ -104,11 +108,22 @@ class AgoraService {
|
||||
try{
|
||||
// Create and publish local audio track
|
||||
this.localAudioTrack = await AgoraRTC.createMicrophoneAudioTrack({
|
||||
AEC: true,
|
||||
AGC: true,
|
||||
ANS: true
|
||||
AEC: true, // 回声消除
|
||||
AGC: true, // 自动增益控制
|
||||
ANS: true, // 噪声抑制
|
||||
encoderConfig: {
|
||||
sampleRate: 48000,
|
||||
stereo: false,
|
||||
bitrate: 128 // 比特率
|
||||
}
|
||||
});
|
||||
|
||||
// 禁用本地音频监听,防止在耳机中听到自己的声音
|
||||
this.localAudioTrack.play = function() {
|
||||
console.log("Local audio playback disabled");
|
||||
return;
|
||||
};
|
||||
|
||||
// Enable VAD (Voice Activity Detection)
|
||||
if (this.vadEnabled && this.localAudioTrack.setVADMode) {
|
||||
this.localAudioTrack.setVADMode(true, this.vadParams);
|
||||
@@ -120,6 +135,8 @@ class AgoraService {
|
||||
}
|
||||
|
||||
// Publish local audio track
|
||||
console.log("this.localAudioTrack:",this.localAudioTrack);
|
||||
|
||||
await this.client.publish([this.localAudioTrack]);
|
||||
return true;
|
||||
}catch(error){
|
||||
@@ -227,10 +244,19 @@ class AgoraService {
|
||||
* 设置VAD回调
|
||||
*/
|
||||
setupVADCallback() {
|
||||
if (!this.localAudioTrack) return;
|
||||
// if (!this.localAudioTrack) return;
|
||||
|
||||
if (!this.localAudioTrack) {
|
||||
return;
|
||||
}
|
||||
if (typeof this.localAudioTrack.setVADMode !== 'function') {
|
||||
console.error("当前 Agora SDK 版本不支持 VAD 功能");}
|
||||
|
||||
// 设置VAD回调
|
||||
this.localAudioTrack.on('vad', (result) => {
|
||||
|
||||
console.log("VAD 事件触发,result.state:", result.state, "result:", result);
|
||||
|
||||
if (!this.inConversation) return;
|
||||
|
||||
if (result.state === 'speech_start') {
|
||||
|
||||
@@ -35,10 +35,10 @@ class ApiService {
|
||||
const response = await this.client.post(
|
||||
`${this.baseUrl}/projects/${this.projectId}/join/`,
|
||||
{
|
||||
"name": "convaiconsole_122624",
|
||||
"name": "convaiconsole_181047",
|
||||
"properties": {
|
||||
"channel": "convaiconsole_122624",
|
||||
"agent_rtc_uid": "29501",
|
||||
"channel": "convaiconsole_181047",
|
||||
"agent_rtc_uid": "28794",
|
||||
"remote_rtc_uids": [
|
||||
"*"
|
||||
],
|
||||
@@ -93,7 +93,7 @@ class ApiService {
|
||||
"enable_metrics": true,
|
||||
"audio_scenario": "default"
|
||||
},
|
||||
"token": "007eJxTYEibc7f9w4Ebac5HtT9ej/CL7KzPrGb+GZmn6/G+kLVp8XsFBgPDRMOU1KRkSzOTRJNks0SLlDQg3yjRLDnVPDHRJGV67630hkBGhhvth1kZGSAQxBdhSM7PK0vMBJLF+Tmp8YZGRmZGJgwMAIF3KEg=",
|
||||
"token": "007eJxTYChiW7ib6cSzPW7fP2xqFVvPqf854sNXniin39cd3pu931SlwGBgmGiYkpqUbGlmkmiSbJZokZIG5BslmiWnmicmmqRcenA7vSGQkaFhbQArIwMEgvgiDMn5eWWJmUCyOD8nNd7QwtDAxJyBAQDAkSkW",
|
||||
"advanced_features": {
|
||||
"enable_aivad": false
|
||||
}
|
||||
|
||||
@@ -206,10 +206,11 @@ export const useChatStore = defineStore('chat', {
|
||||
try {
|
||||
this.isProcessing = true;
|
||||
|
||||
console.log("user send content:",content);
|
||||
// Add user message to the list
|
||||
this.addMessage({
|
||||
id: Date.now(),
|
||||
content,
|
||||
content: content,
|
||||
sender: 'user',
|
||||
timestamp: new Date().toISOString(),
|
||||
});
|
||||
@@ -217,6 +218,9 @@ export const useChatStore = defineStore('chat', {
|
||||
// Send message to API
|
||||
const response = await apiService.sendMessage(content);
|
||||
|
||||
// 检查response返回的内容
|
||||
console.log("AI response:",response);
|
||||
|
||||
// Add AI response to the list
|
||||
if (response && response.content) {
|
||||
this.addMessage({
|
||||
|
||||
@@ -13,7 +13,7 @@ export default defineConfig({
|
||||
server: {
|
||||
host: '0.0.0.0',
|
||||
port: 3000,
|
||||
open: true,
|
||||
open: false,
|
||||
cors:true,
|
||||
proxy:{
|
||||
'/create-api':{
|
||||
|
||||
Reference in New Issue
Block a user