Skip to content

Commit 0ed4702

Browse files
committed
whisper.swiftui: code style changes
1 parent a848aad commit 0ed4702

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

examples/whisper.swiftui/whisper.cpp.swift/LibWhisper.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ actor WhisperContext {
5555
return transcription
5656
}
5757

58-
func system_info() -> String {
58+
private func systemInfo() -> String {
5959
var info = ""
6060
if (ggml_cpu_has_neon() != 0) { info += "NEON " }
6161
if (ggml_cpu_has_metal() != 0) { info += "METAL " }
6262
if (ggml_cpu_has_blas() != 0) { info += "BLAS " }
6363
return String(info.dropLast())
6464
}
6565

66-
func bench_full(modelName: String) async -> String {
66+
func benchFull(modelName: String) async -> String {
6767
let n_threads = Int32(min(4, cpuCount())) // Default in whisper.cpp
6868

6969
let n_mels = whisper_model_n_mels(context)
@@ -118,7 +118,7 @@ actor WhisperContext {
118118

119119
whisper_print_timings(context)
120120

121-
let system_info = self.system_info()
121+
let system_info = self.systemInfo()
122122
let timings: whisper_timings = whisper_get_timings(context).pointee
123123
let encode_ms = String(format: "%.2f", timings.encode_ms)
124124
let decode_ms = String(format: "%.2f", timings.decode_ms)

examples/whisper.swiftui/whisper.swiftui.demo/Models/WhisperState.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import Foundation
22
import SwiftUI
33
import AVFoundation
44

5-
65
@MainActor
76
class WhisperState: NSObject, ObservableObject, AVAudioRecorderDelegate {
87
@Published var isModelLoaded = false
@@ -56,7 +55,7 @@ class WhisperState: NSObject, ObservableObject, AVAudioRecorderDelegate {
5655
return
5756
}
5857
messageLog += "Benchmarking current model\n"
59-
let result = await whisperContext?.bench_full(modelName: "<current>")
58+
let result = await whisperContext?.benchFull(modelName: "<current>")
6059
if (result != nil) { messageLog += result! + "\n" }
6160
}
6261

@@ -70,7 +69,7 @@ class WhisperState: NSObject, ObservableObject, AVAudioRecorderDelegate {
7069
messageLog += "Cannot bench without loaded model\n"
7170
break
7271
}
73-
let result = await whisperContext?.bench_full(modelName: model.name)
72+
let result = await whisperContext?.benchFull(modelName: model.name)
7473
if (result != nil) { messageLog += result! + "\n" }
7574
}
7675
messageLog += "Benchmarking completed\n"

0 commit comments

Comments
 (0)