You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

基于Scrumdinger的iOS Speech Recognition测试无输出问题求助

苹果Speech Recognition API测试问题

我正基于Apple的Scrumdinger应用示例代码测试官方Speech Recognition API,参考了该应用中的MeetingView.swift文件。

我开发了一个简单的测试应用来验证语音识别功能,但未能成功实现。点击开始按钮后对着设备说话,执行print(speechRecognizer.transcript)时没有任何文本输出。

我的测试应用相关代码如下:

import SwiftUI
import AVFoundation
import MediaPlayer

struct ContentView: View {
  
  @State var textValue: String = "The transcription text"
  @StateObject var speechRecognizer = SpeechRecognizer()
  
  private var player: AVPlayer { AVPlayer.sharedDingPlayer }
  
    var body: some View {
        VStack {
            Image(systemName: "mic")
                .imageScale(.large)
                .foregroundColor(.accentColor)
          Text(textValue)
          HStack(spacing: 64) {
            Button {
            
              print("starting")
              self.textValue = "New Text"
              
              player.seek(to: .zero)
              player.play()

              speechRecognizer.reset()
              speechRecognizer.transcribe()

            } label: {
              Text("Start")
            }
            Button {
              print("Stop")
              
              speechRecognizer.stopTranscribing()
              print(speechRecognizer.transcript)
            } label: {
              Text("Stopping")
            }

          }
        }
        .padding()
    }
}


struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

内容的提问来源于stack exchange,提问作者Daryl Wong

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.27 09:12:44