mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Force on-device transcription [experiment]
This commit is contained in:
parent
a02a2c96e0
commit
5dc4427538
@ -38,7 +38,7 @@ private func transcribeAudio(path: String, locale: String) -> Signal<Transcripti
|
|||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
speechRecognizerValue.defaultTaskHint = .unspecified
|
speechRecognizerValue.defaultTaskHint = .dictation
|
||||||
sharedRecognizers[locale] = speechRecognizerValue
|
sharedRecognizers[locale] = speechRecognizerValue
|
||||||
speechRecognizer = speechRecognizerValue
|
speechRecognizer = speechRecognizerValue
|
||||||
|
|
||||||
@ -47,6 +47,7 @@ private func transcribeAudio(path: String, locale: String) -> Signal<Transcripti
|
|||||||
} else {
|
} else {
|
||||||
speechRecognizer.supportsOnDeviceRecognition = false
|
speechRecognizer.supportsOnDeviceRecognition = false
|
||||||
}
|
}
|
||||||
|
speechRecognizer.supportsOnDeviceRecognition = true
|
||||||
}
|
}
|
||||||
|
|
||||||
let tempFilePath = NSTemporaryDirectory() + "/\(UInt64.random(in: 0 ... UInt64.max)).m4a"
|
let tempFilePath = NSTemporaryDirectory() + "/\(UInt64.random(in: 0 ... UInt64.max)).m4a"
|
||||||
@ -57,7 +58,7 @@ private func transcribeAudio(path: String, locale: String) -> Signal<Transcripti
|
|||||||
request.addsPunctuation = true
|
request.addsPunctuation = true
|
||||||
}
|
}
|
||||||
request.requiresOnDeviceRecognition = speechRecognizer.supportsOnDeviceRecognition
|
request.requiresOnDeviceRecognition = speechRecognizer.supportsOnDeviceRecognition
|
||||||
request.shouldReportPartialResults = true
|
request.shouldReportPartialResults = false
|
||||||
|
|
||||||
let task = speechRecognizer.recognitionTask(with: request, resultHandler: { result, error in
|
let task = speechRecognizer.recognitionTask(with: request, resultHandler: { result, error in
|
||||||
if let result = result {
|
if let result = result {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user