多种语言的文字语音转换(支持波斯语和阿拉伯语)

时间:2019-01-30 18:53:39

标签: ios api speech

有人知道iOS的“将语音转换为多种语言的文本” API支持波斯语和阿拉伯语吗? 我使用Swift语言

1 个答案:

答案 0 :(得分:0)

您可以使用isAvailable属性来检查语音识别在特定语言环境中是否可用:

let recognier = SFSpeechRecognizer(locale: Locale(identifier: "fa_IR"))

print(recognier?.isAvailable)   //nil

可悲的是,波斯语不适。

但是它可用于阿拉伯语及其大多数变体:

let recognier = SFSpeechRecognizer(locale: Locale(identifier: "ar_SA"))

print(recognier?.isAvailable)  //Optional(true)

要获取所有受支持的语言环境,请使用类型方法supportedLocales()

print(SFSpeechRecognizer.supportedLocales().sorted {
    $0.description < $1.description
})

哪个输出:

[ar-SA (fixed), ca-ES (fixed), cs-CZ (fixed), da-DK (fixed), de-AT (fixed), 
de-CH (fixed), de-DE (fixed), el-GR (fixed), en-AE (fixed), en-AU (fixed), 
en-CA (fixed), en-GB (fixed), en-ID (fixed), en-IE (fixed), en-IN (fixed), 
en-NZ (fixed), en-PH (fixed), en-SA (fixed), en-SG (fixed), en-US (fixed), 
en-ZA (fixed), es-419 (fixed), es-CL (fixed), es-CO (fixed), es-ES (fixed), 
es-MX (fixed), es-US (fixed), fi-FI (fixed), fr-BE (fixed), fr-CA (fixed), 
fr-CH (fixed), fr-FR (fixed), he-IL (fixed), hi-IN (fixed), hi-IN-translit (fixed), 
hi-Latn (fixed), hr-HR (fixed), hu-HU (fixed), id-ID (fixed), it-CH (fixed), 
it-IT (fixed), ja-JP (fixed), ko-KR (fixed), ms-MY (fixed), nb-NO (fixed),
nl-BE (fixed), nl-NL (fixed), pl-PL (fixed), pt-BR (fixed), pt-PT (fixed),
ro-RO (fixed), ru-RU (fixed), sk-SK (fixed), sv-SE (fixed), th-TH (fixed),
tr-TR (fixed), uk-UA (fixed), vi-VN (fixed), wuu-CN (fixed), yue-CN (fixed), 
zh-CN (fixed), zh-HK (fixed), zh-TW (fixed)]