feat(wechat): 关注公众号后自动回复欢迎语(被动回复,可后台配置) #12
@@ -201,9 +201,16 @@ export class VoiceClient {
|
||||
if (!navigator.mediaDevices?.getUserMedia) {
|
||||
throw new Error("此窗口暂不支持麦克风(原生壳需授权/安全上下文)。用浏览器打开 localhost:5173 可直接说话。");
|
||||
}
|
||||
const stream = await navigator.mediaDevices.getUserMedia({
|
||||
audio: { channelCount: 1, echoCancellation: true, noiseSuppression: true },
|
||||
});
|
||||
// 先试带回声消除等约束(浏览器更好),WKWebView(原生壳)不认高级约束会抛 "Invalid constraint",
|
||||
// 退回最简 {audio:true}(最兼容;多数实现默认已开回声消除)。
|
||||
let stream: MediaStream;
|
||||
try {
|
||||
stream = await navigator.mediaDevices.getUserMedia({
|
||||
audio: { echoCancellation: true, noiseSuppression: true, channelCount: 1 },
|
||||
});
|
||||
} catch {
|
||||
stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
||||
}
|
||||
this.micStream = stream;
|
||||
const ctx = new AudioContext();
|
||||
this.micCtx = ctx;
|
||||
|
||||
Reference in New Issue
Block a user