WhisperKit
WhisperKit copied to clipboard
how to fix "Ambiguous use of 'transcribe(audioPath:decodeOptions:callback:)'"
i try many way, but still show:Ambiguous use of 'transcribe(audioPath:decodeOptions:callback:)
Here is code:
func stopRecording() {
audioRecorder?.stop()
if let url = audioRecorder?.url {
transcribeAudio(audioPath: url.path)
}
}
func transcribeAudio(audioPath: String) {
Task {
do {
let whisper = try await WhisperKit()
let results = try await whisper.transcribe(audioPath: audioPath)
DispatchQueue.main.async {
if let result = results.first, !result.text.isEmpty {
self.transcription = result.text
let newRecording = Recording(
name: "Recording \(self.recordings.count + 1)",
createdAt: Date(),
fileURL: URL(fileURLWithPath: audioPath),
transcript: result.text
)
self.recordings.append(newRecording)
}
}
} catch {
DispatchQueue.main.async {
print("Transcription failed: \(error)")
}
}
}
}