@@ -29,6 +29,47 @@ describe('Audio Client Tests', () => {
2929 try {
3030 const audioClient = model . createAudioClient ( ) ;
3131 expect ( audioClient ) . to . not . be . undefined ;
32+
33+ audioClient . settings . language = 'en' ;
34+ audioClient . settings . temperature = 0.0 ; // for deterministic results
35+
36+ const response = await audioClient . transcribe ( AUDIO_FILE_PATH ) ;
37+
38+ expect ( response ) . to . not . be . undefined ;
39+ expect ( response . text ) . to . not . be . undefined ;
40+ expect ( response . text ) . to . be . a ( 'string' ) ;
41+ expect ( response . text . length ) . to . be . greaterThan ( 0 ) ;
42+ expect ( response . text ) . to . equal ( EXPECTED_TEXT ) ;
43+ console . log ( `Response: ${ response . text } ` ) ;
44+ } finally {
45+ await model . unload ( ) ;
46+ }
47+ } ) ;
48+
49+ it ( 'should transcribe audio without streaming with temperature' , async function ( ) {
50+ this . timeout ( 30000 ) ;
51+ const manager = getTestManager ( ) ;
52+ const catalog = manager . catalog ;
53+
54+ const cachedModels = await catalog . getCachedModels ( ) ;
55+ expect ( cachedModels . length ) . to . be . greaterThan ( 0 ) ;
56+
57+ const cachedVariant = cachedModels . find ( m => m . alias === WHISPER_MODEL_ALIAS ) ;
58+ expect ( cachedVariant , 'whisper-tiny should be cached' ) . to . not . be . undefined ;
59+
60+ const model = await catalog . getModel ( WHISPER_MODEL_ALIAS ) ;
61+ expect ( model ) . to . not . be . undefined ;
62+ if ( ! model || ! cachedVariant ) return ;
63+
64+ model . selectVariant ( cachedVariant . id ) ;
65+ await model . load ( ) ;
66+
67+ try {
68+ const audioClient = model . createAudioClient ( ) ;
69+ expect ( audioClient ) . to . not . be . undefined ;
70+
71+ audioClient . settings . language = 'en' ;
72+ audioClient . settings . temperature = 0.0 ; // for deterministic results
3273
3374 const response = await audioClient . transcribe ( AUDIO_FILE_PATH ) ;
3475
@@ -65,6 +106,50 @@ describe('Audio Client Tests', () => {
65106 const audioClient = model . createAudioClient ( ) ;
66107 expect ( audioClient ) . to . not . be . undefined ;
67108
109+ audioClient . settings . language = 'en' ;
110+ audioClient . settings . temperature = 0.0 ; // for deterministic results
111+
112+ let fullResponse = '' ;
113+ await audioClient . transcribeStreaming ( AUDIO_FILE_PATH , ( chunk ) => {
114+ expect ( chunk ) . to . not . be . undefined ;
115+ expect ( chunk . text ) . to . not . be . undefined ;
116+ expect ( chunk . text ) . to . be . a ( 'string' ) ;
117+ expect ( chunk . text . length ) . to . be . greaterThan ( 0 ) ;
118+ fullResponse += chunk . text ;
119+ } ) ;
120+
121+ console . log ( `Full response: ${ fullResponse } ` ) ;
122+ expect ( fullResponse ) . to . equal ( EXPECTED_TEXT ) ;
123+ } finally {
124+ await model . unload ( ) ;
125+ }
126+ } ) ;
127+
128+ it ( 'should transcribe audio with streaming with temperature' , async function ( ) {
129+ this . timeout ( 30000 ) ;
130+ const manager = getTestManager ( ) ;
131+ const catalog = manager . catalog ;
132+
133+ const cachedModels = await catalog . getCachedModels ( ) ;
134+ expect ( cachedModels . length ) . to . be . greaterThan ( 0 ) ;
135+
136+ const cachedVariant = cachedModels . find ( m => m . alias === WHISPER_MODEL_ALIAS ) ;
137+ expect ( cachedVariant , 'whisper-tiny should be cached' ) . to . not . be . undefined ;
138+
139+ const model = await catalog . getModel ( WHISPER_MODEL_ALIAS ) ;
140+ expect ( model ) . to . not . be . undefined ;
141+ if ( ! model || ! cachedVariant ) return ;
142+
143+ model . selectVariant ( cachedVariant . id ) ;
144+ await model . load ( ) ;
145+
146+ try {
147+ const audioClient = model . createAudioClient ( ) ;
148+ expect ( audioClient ) . to . not . be . undefined ;
149+
150+ audioClient . settings . language = 'en' ;
151+ audioClient . settings . temperature = 0.0 ; // for deterministic results
152+
68153 let fullResponse = '' ;
69154 await audioClient . transcribeStreaming ( AUDIO_FILE_PATH , ( chunk ) => {
70155 expect ( chunk ) . to . not . be . undefined ;
0 commit comments