@aiyiran/myclaw 1.0.103 → 1.0.104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/assets/myclaw-inject.js
CHANGED
|
@@ -414,7 +414,7 @@
|
|
|
414
414
|
APPID: 'de6ec59e',
|
|
415
415
|
APISecret: 'ZTA3ZDU3YjAyNDUyZGVkNjQwMGM5MWNi',
|
|
416
416
|
APIKey: '37104a0463a5460d7571869324b667d5',
|
|
417
|
-
vcn: '
|
|
417
|
+
vcn: 'x4_yezi', // 小露 - 普通话女声
|
|
418
418
|
onAudio: function (audioBuffer) {
|
|
419
419
|
console.log('[myclaw-tts] audio chunk:', audioBuffer.byteLength, 'bytes');
|
|
420
420
|
},
|
package/package.json
CHANGED
package/patch-manifest.json
CHANGED
|
@@ -107,9 +107,33 @@
|
|
|
107
107
|
VoiceOutput.prototype._playAudio = function (audioBuffer) {
|
|
108
108
|
var self = this;
|
|
109
109
|
|
|
110
|
+
// 尝试 Web Audio API(可以解码 MP3)
|
|
111
|
+
try {
|
|
112
|
+
this._initAudioContext();
|
|
113
|
+
this.audioContext.decodeAudioData(audioBuffer.slice(0), function (decodedBuffer) {
|
|
114
|
+
console.log('[tts] decoded audio:', decodedBuffer.duration, 's,', decodedBuffer.numberOfChannels, 'ch');
|
|
115
|
+
self._playBuffer(decodedBuffer);
|
|
116
|
+
}, function (err) {
|
|
117
|
+
console.error('[tts] decode error, trying blob URL:', err);
|
|
118
|
+
// fallback: 用 Blob URL 方式
|
|
119
|
+
self._playAudioBlob(audioBuffer);
|
|
120
|
+
});
|
|
121
|
+
return;
|
|
122
|
+
} catch (e) {
|
|
123
|
+
console.error('[tts] Web Audio API error:', e);
|
|
124
|
+
// fallback: 用 Blob URL 方式
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
this._playAudioBlob(audioBuffer);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
VoiceOutput.prototype._playAudioBlob = function (audioBuffer) {
|
|
131
|
+
var self = this;
|
|
132
|
+
|
|
110
133
|
// 创建 Blob URL 用于 <audio> 元素播放
|
|
111
134
|
var mimeType = this.aue === 'lame' ? 'audio/mpeg' : 'audio/wav';
|
|
112
135
|
var blob = new Blob([audioBuffer], { type: mimeType });
|
|
136
|
+
console.log('[tts] blob size:', blob.size, 'type:', mimeType);
|
|
113
137
|
var blobUrl = URL.createObjectURL(blob);
|
|
114
138
|
|
|
115
139
|
// 停止之前的播放
|