Skip to content

Commit 8d523f9

Browse files
committed
Add test case for token-level transcription
1 parent 8f776b5 commit 8d523f9

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import XCTest
2+
@testable import SwiftWhisper
3+
4+
class TranscriptionParamterTests: ResourceDependentTestCase, ModelFileTestCase, AudioFileTestCase {
5+
let timeout: TimeInterval = 60
6+
7+
@available(iOS 13, macOS 10.15, *)
8+
func testParametersMaxLen() async throws {
9+
let params = WhisperParams()
10+
params.language = .english
11+
params.max_len = 1
12+
params.token_timestamps = true
13+
14+
let modelURL = await tinyModelURL!
15+
let whisper = Whisper(fromFileURL: modelURL, withParams: params)
16+
let jfk = jfkAudioFrames!
17+
18+
let segments = try await whisper.transcribe(audioFrames: jfk)
19+
20+
// The JFK audio contains 23 non-empty segments
21+
XCTAssert(segments.filter { !$0.text.isEmpty }.count == 23)
22+
}
23+
}

0 commit comments

Comments
 (0)