请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

程序好像运行不了了

https://img1.sycdn.imooc.com/szimg/666c38d6098a0fb904180512.jpg log就打印到这里,感觉RTC连接就没有建立成功


https://img1.sycdn.imooc.com/szimg/666c3987098c90fd15800382.jpg 这个回调的代码就没有打印,不知道是什么原因···

正在回答 回答被采纳积分+3

5回答

zero菌 2024-06-24 12:17:58

ws连接目前看着也正常建立了

https://img1.sycdn.imooc.com/szimg/6678f36009cda5fe10090191.jpg


不知道有没有可能和这个issue有关

https://img1.sycdn.imooc.com/szimg/6678f32f09287ce006970467.jpg

0 回复 有任何疑惑可以回复我~
提问者 慕娘6279593 2024-06-24 10:26:25

回复 tomiezhang:我就是一开始就加载不出这个虚拟人物,下面是我的docker容器的启动log你看看有什么问题吗:

2024-06-24 10:14:13 8:C 24 Jun 2024 02:14:13.793 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo

2024-06-24 10:14:13 8:C 24 Jun 2024 02:14:13.793 # Redis version=6.0.16, bits=64, commit=00000000, modified=0, pid=8, just started

2024-06-24 10:14:13 8:C 24 Jun 2024 02:14:13.793 # Configuration loaded

2024-06-24 10:14:13 8:M 24 Jun 2024 02:14:13.798 * Running mode=standalone, port=6379.

2024-06-24 10:14:13 8:M 24 Jun 2024 02:14:13.798 # Server initialized

2024-06-24 10:14:13 8:M 24 Jun 2024 02:14:13.798 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo madvise > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled (set to 'madvise' or 'never').

2024-06-24 10:14:13 8:M 24 Jun 2024 02:14:13.804 * Ready to accept connections

2024-06-24 10:14:24 INFO:     192.168.65.1:41137 - "GET /static/index.html HTTP/1.1" 304 Not Modified

2024-06-24 10:17:56 INFO:     192.168.65.1:34462 - "GET /static/index.html HTTP/1.1" 304 Not Modified

2024-06-24 10:18:19 INFO:     192.168.65.1:48215 - "GET /static/index.html HTTP/1.1" 304 Not Modified

2024-06-24 10:19:14 INFO:     192.168.65.1:41762 - "GET /static/index.html HTTP/1.1" 304 Not Modified

2024-06-24 10:14:18 WARNING:root:USER_AGENT environment variable not set, consider setting it to identify your requests.

2024-06-24 10:14:18 INFO:     Started server process [29]

2024-06-24 10:14:18 INFO:     Waiting for application startup.

2024-06-24 10:14:18 INFO:     Application startup complete.

2024-06-24 10:14:18 INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)


我一开始怀疑是turnserver没有启动,但是感觉好像又不像啊···


0 回复 有任何疑惑可以回复我~
  • 提问者 慕娘6279593 #1
    # linux ps aux
    /bin/sh: 1: linux: not found
    # ps aux  
    USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
    root         1  0.0  0.0   2304  1280 ?        Ss   02:51   0:00 sh -c turnserver -c /etc/turnserver.conf --listening-ip=0.0.0.0 --listening-port=
    root         7  0.2  0.7 1086884 28576 ?       Sl   02:51   0:00 turnserver -c /etc/turnserver.conf --listening-ip=0.0.0.0 --listening-port=3478
    root         8  0.2  0.4  62668 16696 ?        Sl   02:51   0:00 redis-server 0.0.0.0:6379
    root        29  0.9  2.8 603300 114132 ?       Sl   02:51   0:03 /usr/bin/python3 /usr/local/bin/uvicorn server:app --host 0.0.0.0 --port 8000
    root        43  0.0  0.0   2304  1280 pts/0    Ss   02:58   0:00 /bin/sh
    root        49  0.0  0.0   6408  2432 pts/0    R+   02:58   0:00 ps aux
    # 
    
    看起来服务好像没有问题···
    回复 有任何疑惑可以回复我~ 2024-06-24 10:59:14
  • tomiezhang 回复 提问者 慕娘6279593 #2
    你的区域选择的是westus2吗?avart这个只能在部分区域可用
    回复 有任何疑惑可以回复我~ 9天前
  • 提问者 慕娘6279593 回复 tomiezhang #3
    回复 tomiezhang:不能使用westus2啊,因为使用了westus2会出现下面401的问题,这个是我一开始调试了半天才发现的,只能使用eastus的方式
    
    westus2.tts.speech.microsoft.com/cognitiveservices/avatar/relay/token/v1:1 
            
    Failed to load resource: the server responded with a status of 401 ()
    index.html:1 Uncaught SyntaxError: Unexpected end of JSON input
        at JSON.parse (<anonymous>)
        at XMLHttpRequest.<anonymous> (index.html:78:45)
    
    
    
                xhr.setRequestHeader("Ocp-Apim-Subscription-Key", subscriptionKey);
                xhr.addEventListener("readystatechange",function(){
                    if (this.readyState === 4){
                        var responseData = JSON.parse(this.responseText);                 问题会出现在这一行;
                        var iceServerUrl = responseData.Urls[0]
                        var iceServerUsername = responseData.Username;
                        var iceServerCredential = responseData.Password;
    
    
    
    我原来是按照你的课程创建了一个telegramAI 的语音服务选的服务器位置是eastus,难道你的意思是从新再注册一个westus2的语音服务,这个代码换成westus2再试试?···
    回复 有任何疑惑可以回复我~ 8天前
zero菌 2024-06-24 00:38:01

我也遇到同样的问题,请问解决了吗

0 回复 有任何疑惑可以回复我~
  • 提问者 慕娘6279593 #1
    暂时还没有···
    回复 有任何疑惑可以回复我~ 2024-06-24 10:25:41
tomiezhang 2024-06-19 09:02:22
  1.  确保 ICE 候选者已经被成功收集并传递给对等方

  2. 确保信令交换过程已经正确完成

  3. 检查网络好防火墙

  4. 浏览器是否支持webTRC更换浏览器尝试

    增加了一些调试断点可以看下日志,另外确保你的turnserver.conf配置与课程配置一致

  1. // 创建WebRTC连接
    console.log("creating WebRTC connection");
    console.log("ice server url: " + iceServerUrl);
    console.log("ice server username: " + iceServerUsername);
    console.log("ice server credential: " + iceServerCredential);
    
    peerConnection = new RTCPeerConnection({
        iceServers: [
            {
                urls: [iceServerUrl],
                username: iceServerUsername,
                credential: iceServerCredential
            }
        ]
    });
    
    // 添加 ICE 候选者事件监听器
    peerConnection.onicecandidate = function(event) {
        if (event.candidate) {
            console.log("New ICE candidate: ", event.candidate);
            // Send the candidate to the remote peer via signaling server
        } else {
            console.log("All ICE candidates have been sent");
        }
    };
    
    // 添加 ICE 连接状态变化事件监听器
    peerConnection.oniceconnectionstatechange = function() {
        console.log("avatar ice connection state changed to " + peerConnection.iceConnectionState);
        if (peerConnection.iceConnectionState === "connected") {
            console.log("avatar connected");
        }
        if (peerConnection.iceConnectionState === "disconnected" || peerConnection.iceConnectionState === "failed" || peerConnection.iceConnectionState === "closed") {
            console.log("avatar disconnected");
        }
    };
    
    // 创建音频流
    peerConnection.addTransceiver("video", { direction: "sendrecv" });
    peerConnection.addTransceiver("audio", { direction: "sendrecv" });
    
    // 合成
    var avatarSynthesizer = new SpeechSDK.AvatarSynthesizer(speechConfing, avatarConfig);
    
    // 开始合成
    avatarSynthesizer.startAvatarAsync(peerConnection).then((r) => {
        console.log("Avatar started ID:" + r.resultId)
        console.log("avatar started");
        // 创建对话区域
        var chatInput = document.createElement("input");
        chatInput.type = "text";
        chatInput.placeholder = "Type your message here";
        chatInput.id = "chatInput";
        chatInput.style = "width:300px;height:50px;";
        document.body.appendChild(chatInput);
        // 音色选择
        var voiceSelect = document.createElement("select");
        voiceSelect.id = "voiceSelect";
        voiceSelect.style = "width:100px;height:50px;";
        voiceSelect.innerHTML = `
            <option value="zh-HK-HiuMaanNeural">中文粤语</option>
            <option value="zh-TW-HsiaoChenNeural">中文台湾</option>
            <option value="zh-CN-shaanxi-XiaoniNeural">中文陕西话</option>
            <option value="zh-CN-liaoning-XiaobeiNeural">中文东北话</option>
            <option value="zh-CN-XiaomoNeural" selected>中文普通话</option>
            <option value="th-TH-PremwadeeNeural">泰语</option>
        `;
        document.body.appendChild(voiceSelect);
        // 发送按钮
        var sendButton = document.createElement("button");
        sendButton.innerHTML = "Send";
        sendButton.style = "width:100px;height:50px;";
        document.body.appendChild(sendButton);
        // 发送按钮事件
        sendButton.addEventListener("click", function() {
            var videoPlayer = document.getElementById("videoPlayer");
            var audioPlayer = document.getElementById("audioPlayer");
            videoPlayer.muted = false;
            audioPlayer.muted = false;
            videoPlayer.play();
            audioPlayer.play();
            console.log("send button clicked");
            chatWithAI(avatarSynthesizer);
        });
    }).catch((e) => {
        console.error("avatar start failed: " + e);
    });
0 回复 有任何疑惑可以回复我~
  • 提问者 慕娘6279593 #1
    老师,我用了你上面的代码重新build编译以及生成容器了,但是与原来log打印没有区别,你上面提到的4点:
    
    1 确保 ICE 候选者已经被成功收集并传递给对等方;2 确保信令交换过程已经正确完成;3 检查网络好防火墙;4 浏览器是否支持webTRC更换浏览器尝试; 
    
    其中1,2没有办法确认因为onicecandidate,ontrack,oniceconnectionstatechange 均未打印log就像都没有运行;
    
    第三点应该可以排除我使用了普通网络以及VPN都没有效果;第4点应该可以可以排除我使用的是比较新的Google浏览器;
    
    所以还是不清楚问题到底出在哪,另外我想问问这个程序你现在跑可以正常运行吗,会不会是微软那边有变更呢···
    回复 有任何疑惑可以回复我~ 2024-06-19 17:06:35
  • tomiezhang 回复 提问者 慕娘6279593 #2
    回复 慕娘6279593:可以使用没问题
    回复 有任何疑惑可以回复我~ 2024-06-23 16:52:51
tomiezhang 2024-06-15 11:09:21

能拿到avatar id说明已经建立好了对等链接,本地的docker image有没有删除重构下呢?

0 回复 有任何疑惑可以回复我~
  • 提问者 慕娘6279593 #1
    我调试删除重构build很多次了,就是onice connectionstatechange这个回调不运行,以及ontrack这个回调也不运行,不知道是什么原因…
    回复 有任何疑惑可以回复我~ 2024-06-15 17:02:53
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信