(base64: string)
| 33 | |
| 34 | // base64 转 Int16Array |
| 35 | export function base64ToInt16Array(base64: string): Int16Array { |
| 36 | const binary = atob(base64); |
| 37 | const bytes = new Uint8Array(binary.length); |
| 38 | binary.split('').forEach((char, i) => bytes[i] = char.charCodeAt(0)); |
| 39 | return new Int16Array(bytes.buffer); |
| 40 | } |
| 41 | |
| 42 | // 将 Int16Array 转换为 WAV 格式的 Buffer |
| 43 | export function int16ArrayToWavBuffer(int16Array: Int16Array, sampleRate = 16000): Buffer { |
no outgoing calls
no test coverage detected