mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-21 12:41:20 -08:00
feat: add WAV format support for audio chunks in artplayer-plugin-asr
- Implemented pcmToWav function to convert PCM audio data to WAV format. - Updated onAudioChunk callback to receive both PCM and WAV buffers. - Modified TypeScript definitions to reflect changes in onAudioChunk parameter and append method.
This commit is contained in:
1 parent
62835bb042
commit
10337ddb1d
6 files changed
+81
-13
No files matched your search
@@ -10,8 +10,8 @@ var art = new Artplayer({
|
||||
interval: 40,
|
||||
sampleRate: 16000,
|
||||
autoHideTimeout: 10000,
|
||||
// Use your AI tool to convert buffer into subtitles
|
||||
onAudioChunk: (buffer) => startAsr(buffer),
|
||||
// Use your AI tool to convert pcm/wav into subtitles
|
||||
onAudioChunk: ({ pcm, wav }) => startAsr(pcm),
|
||||
}),
|
||||
]
|
||||
});
|
||||
|
||||
+7
-2
@@ -3,19 +3,24 @@ import type Artplayer from 'artplayer';
|
||||
export = artplayerPluginAsr;
|
||||
export as namespace artplayerPluginAsr;
|
||||
|
||||
interface AudioChunk {
|
||||
pcm: ArrayBuffer;
|
||||
wav: ArrayBuffer;
|
||||
}
|
||||
|
||||
interface AsrPluginOption {
|
||||
length?: number;
|
||||
interval?: number;
|
||||
sampleRate?: number;
|
||||
autoHideTimeout?: number;
|
||||
onAudioChunk?: (buffer: ArrayBuffer) => void | Promise<void>;
|
||||
onAudioChunk?: (chunk: AudioChunk) => void | Promise<void>;
|
||||
}
|
||||
|
||||
interface AsrPluginInstance {
|
||||
name: 'artplayerPluginAsr';
|
||||
stop: () => void;
|
||||
hide: () => void;
|
||||
append: () => void;
|
||||
append: (subtitle: string) => void;
|
||||
}
|
||||
|
||||
declare function artplayerPluginAsr(option?: AsrPluginOption): (art: Artplayer) => AsrPluginInstance;
|
||||
Reference in new issue
Block a user