SFSpeechRecognizer multiple languages
Asked Answered
J

2

5

I am building a search that supports voice recognition and transforms speech to text so I am using SFSpeechRecognizer. But the problem is that I need to support multiple languages at the same time such as ("en_US", "fr", vi, ar).

The main idea is that the user can speak for example 1 word in English and the other in French and I want the engine to detect this.

Currently, I am using this to set my main language

ENGLISH:

private let speechRecognizer = SFSpeechRecognizer(locale: Locale.init(identifier: "en_US"))!

FRENCH:

 private let speechRecognizer = SFSpeechRecognizer(locale: Locale.init(identifier: "fr"))!

Every language I need to set it separately.

Is there a way so SFSpeechRecognizer supports multiple languages at the same time?

Jaynes answered 23/5, 2019 at 8:7 Comment(2)
I'm also trying to achieve same but still no luck for me. Do you have any solutions? please let me know.Trews
you need to make you own core ml model for Speech to text to detect multiple language support.Fan
J
1

Old question, but no answer yet...

You cannot use more locale in just one SFSpeechRecognizeer, but you can manage multiple SFSpeechRecognizers at the same time, like this:

let italian = SFSpeechRecognizer(locale: Locale(identifier: "it-IT"))
let english = SFSpeechRecognizer(locale: Locale(identifier: "en-US"))

set delegate for all of them:

italian.delegate = self
english.delegate = self

create double, triple or multiple logic as needed like:

self.recognitionTaskOne = italian?.recognitionTask(with: recognitionRequest, resultHandler: { (result, error) in
     // Your code
})
self.recognitionTaskTwo = english?.recognitionTask(with: recognitionRequest, resultHandler: { (result, error) in
     // Your code
})

and so on...

For your specific request:

The main idea is that the user can speak for example 1 word in English and the other in French and I want the engine to detect this.

I'm affraid that you need to process all the outputs and compare them. Anyway, I noticed that if I set one locale (for example Italian) and then the user speaks in English, the system gets some English too. This works just for English... I'm not sure, but I suppose that whatever locale you set, English is always understood by default.

Jeneejenei answered 8/10, 2020 at 8:40 Comment(1)
HI @Giuseppe Garassino I have tried but for one of my request i am getting SpeechApp[4764:92774] [Utility] +[AFAggregator logDictationFailedWithError:] Error Domain=kAFAssistantErrorDomain Code=203 "Retry" UserInfo={NSLocalizedDescription=Retry, NSUnderlyingError=0x600001c71470 {Error Domain=SiriSpeechErrorDomain Code=1 "(null)"}}Neology
A
0

It seems the simultaneous recognization of multiple languages is still a No. I set the locale to Chinese and it did recognize some English if the speaker mixed English into Chinese, but if the speaker says something solely in English, the recognizer gets confused.

Athamas answered 5/4 at 7:58 Comment(1)
This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. To get notified when this question gets new answers, you can follow this question. Once you have enough reputation, you can also add a bounty to draw more attention to this question. - From ReviewChristianechristiania

© 2022 - 2024 — McMap. All rights reserved.