@@ -185,8 +185,16 @@ export async function transcribeAudio(
185185 case 'azure-asr' :
186186 return await transcribeAzureASR ( config , audioBuffer ) ;
187187
188+ case 'funasr-asr' :
189+ return await transcribeWavOpenAICompatibleASR ( config , audioBuffer , 'funasr-asr' , 'FunASR' ) ;
190+
188191 case 'lemonade-asr' :
189- return await transcribeLemonadeASR ( config , audioBuffer ) ;
192+ return await transcribeWavOpenAICompatibleASR (
193+ config ,
194+ audioBuffer ,
195+ 'lemonade-asr' ,
196+ 'Lemonade' ,
197+ ) ;
190198
191199 default :
192200 if ( isCustomASRProvider ( config . providerId ) ) {
@@ -197,29 +205,31 @@ export async function transcribeAudio(
197205}
198206
199207/**
200- * Lemonade ASR implementation ( OpenAI-compatible multipart transcription) .
208+ * WAV-only OpenAI-compatible multipart transcription.
201209 *
202- * Lemonade currently supports WAV input and JSON response format .
210+ * Used by local providers whose transcription endpoint accepts WAV and JSON .
203211 */
204- async function transcribeLemonadeASR (
212+ async function transcribeWavOpenAICompatibleASR (
205213 config : ASRModelConfig ,
206214 audioBuffer : Buffer | Blob ,
215+ providerId : 'funasr-asr' | 'lemonade-asr' ,
216+ providerName : string ,
207217) : Promise < ASRTranscriptionResult > {
208- const baseUrl = ( config . baseUrl || ASR_PROVIDERS [ 'lemonade-asr' ] . defaultBaseUrl || '' ) . replace (
218+ const baseUrl = ( config . baseUrl || ASR_PROVIDERS [ providerId ] . defaultBaseUrl || '' ) . replace (
209219 / \/ $ / ,
210220 '' ,
211221 ) ;
212222
213223 const audioBlob = await toAudioBlob ( audioBuffer ) ;
214224 if ( ! ( await isWavAudio ( audioBlob ) ) ) {
215225 throw new Error (
216- 'Lemonade ASR currently supports WAV input only. Recordings should be converted to WAV before upload.' ,
226+ ` ${ providerName } ASR currently supports WAV input only. Recordings should be converted to WAV before upload.` ,
217227 ) ;
218228 }
219229
220230 const formData = new FormData ( ) ;
221231 formData . set ( 'file' , audioBlob , 'audio.wav' ) ;
222- formData . set ( 'model' , config . modelId || ASR_PROVIDERS [ 'lemonade-asr' ] . defaultModelId ) ;
232+ formData . set ( 'model' , config . modelId || ASR_PROVIDERS [ providerId ] . defaultModelId ) ;
223233 formData . set ( 'response_format' , 'json' ) ;
224234 if ( config . language && config . language !== 'auto' ) {
225235 formData . set ( 'language' , config . language ) ;
@@ -236,7 +246,7 @@ async function transcribeLemonadeASR(
236246 if ( errorText . includes ( 'audio is empty' ) || errorText . includes ( 'too short' ) ) {
237247 return { text : '' } ;
238248 }
239- throw new Error ( `Lemonade ASR API error: ${ errorText || response . statusText } ` ) ;
249+ throw new Error ( `${ providerName } ASR API error: ${ errorText || response . statusText } ` ) ;
240250 }
241251
242252 const data = await response . json ( ) ;
0 commit comments