File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,6 @@ import Speech
5353 attributeOptions: outputFormat. needsAudioTimeRange ? [ . audioTimeRange] : [ ]
5454 )
5555 let modules : [ any SpeechModule ] = [ transcriber]
56-
5756 let installed = await Set ( SpeechTranscriber . installedLocales)
5857 if !installed. map ( { $0. identifier ( . bcp47) } ) . contains ( locale. identifier ( . bcp47) ) {
5958 if let request = try await AssetInventory . assetInstallationRequest ( supporting: modules) {
@@ -98,9 +97,10 @@ import Speech
9897 await MainActor . run {
9998 transcript += result. text
10099 }
101- let progress = result. resultsFinalizationTime. seconds / audioFileDuration
100+ let progress = max ( min ( result. resultsFinalizationTime. seconds / audioFileDuration, 1 ) , 0 )
102101 var percent = progress. formatted ( . percent. precision ( . fractionLength( 0 ) ) )
103- percent = String ( String ( repeating: " " , count: 4 - percent. count) ) + percent
102+ var oneHundredPercent = 1.0 . formatted ( . percent. precision ( . fractionLength( 0 ) ) )
103+ percent = String ( String ( repeating: " " , count: max ( oneHundredPercent. count - percent. count, 0 ) ) ) + percent
104104 let message = " [ \( percent) ] \( String ( result. text. characters) . trimmingCharacters ( in: . whitespaces) . prefix ( terminalColumns - 9 ) ) "
105105 progressHandler ( message)
106106 }
You can’t perform that action at this time.
0 commit comments