argmaxinc / WhisperKit

On-device Speech Recognition for Apple Silicon
http://argmaxinc.com/blog/whisperkit
MIT License
3.92k stars 331 forks source link

After Steps, I can't start my project. #19

Closed JinYu1998 closed 9 months ago

JinYu1998 commented 9 months ago
  1. I created a new project in xcode, named WhisperKit.
  2. I added WhisperKit according to the steps.
  3. I added the following code to WhisperKit/WhisperKit/WhisperKitApp

import SwiftUI
import WhisperKit

@main
struct WhisperKitApp: App {
    init() {
        Task {
            do {
                let pipe = try? await WhisperKit()
                let transcription = try? await pipe!.transcribe(audioPath: "Audio/output-lang.wav")?.text
                print(transcription)
            } catch {
                print("Error: \(error)")
            }
        }
    }

    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

Then I get an error : Cannot call value of non-function type 'module<WhisperKit>'

What should I do to solve this problem? tks.

ZachNagengast commented 9 months ago

Following up from this thread in discord, there appears to be a naming conflict in your app where something is already using the name WhisperKit so importing it is ineffective. I recommend trying to find the naming conflict in your project and using a different name so that the WhisperKit swift package can be imported. At that point, you may want to consider moving the initialization into your ContentView or some view model class so it can be managed more easily within your app.

ZachNagengast commented 9 months ago

Looks like this was resolved: https://discord.com/channels/1171912382512115722/1201632730446823444/1206875382712635432