javascript – How do you utilize a Japanese voice with speechSynthesis in Safari/iOS 18?

0
15
javascript – How do you utilize a Japanese voice with speechSynthesis in Safari/iOS 18?


In Safari, it’s essential to set a voice on an utterance in addition to the lang property to get it to make use of the right language.

On different platforms, speechSynthesis.getVoices() returns all accessible voices on the gadget. You’ll be able to then filter to the language you want and choose one.

Nevertheless, though I’ve a Japanese voice downloaded onto my iPhone 16 (simulator, iOS 18.0), it is not included within the array returned from getVoices.

I’ve tried setting Japanese as a most well-liked language. I’ve tried altering to a different Japanese voice beneath Communicate Choice within the accessibility settings. I’ve tried setting the html lang property to ‘ja’. There may be nonetheless no Japanese voice current within the array.

This is the array:

0
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.ar-001.Maged", identify: "Majed", lang: "ar-001", localService: true, default: true}
1
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.bg-BG.Daria", identify: "Daria", lang: "bg-BG", localService: true, default: true}
2
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.ca-ES.Montserrat", identify: "Montse", lang: "ca-ES", localService: true, default: true}
3
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.cs-CZ.Zuzana", identify: "Zuzana", lang: "cs-CZ", localService: true, default: true}
4
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.da-DK.Sara", identify: "Sara", lang: "da-DK", localService: true, default: true}
5
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.de-DE.Anna", identify: "Anna", lang: "de-DE", localService: true, default: true}
6
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.el-GR.Melina", identify: "Melina", lang: "el-GR", localService: true, default: true}
7
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.en-AU.Karen", identify: "Karen", lang: "en-AU", localService: true, default: true}
8
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.en-IE.Moira", identify: "Moira", lang: "en-IE", localService: true, default: true}
9
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.en-IN.Rishi", identify: "Rishi", lang: "en-IN", localService: true, default: true}
10
SpeechSynthesisVoice {voiceURI: "com.apple.speech.synthesis.voice.Trinoids", identify: "Trinoids", lang: "en-US", localService: true, default: true}
11
SpeechSynthesisVoice {voiceURI: "com.apple.speech.synthesis.voice.Albert", identify: "Albert", lang: "en-US", localService: true, default: true}
12
SpeechSynthesisVoice {voiceURI: "com.apple.speech.synthesis.voice.Hysterical", identify: "Jester", lang: "en-US", localService: true, default: true}
13
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.en-US.Samantha", identify: "Samantha", lang: "en-US", localService: true, default: true}
14
SpeechSynthesisVoice {voiceURI: "com.apple.speech.synthesis.voice.Whisper", identify: "Whisper", lang: "en-US", localService: true, default: true}
15
SpeechSynthesisVoice {voiceURI: "com.apple.speech.synthesis.voice.Princess", identify: "Celebrity", lang: "en-US", localService: true, default: true}
16
SpeechSynthesisVoice {voiceURI: "com.apple.speech.synthesis.voice.Bells", identify: "Bells", lang: "en-US", localService: true, default: true}
17
SpeechSynthesisVoice {voiceURI: "com.apple.speech.synthesis.voice.Organ", identify: "Organ", lang: "en-US", localService: true, default: true}
18
SpeechSynthesisVoice {voiceURI: "com.apple.speech.synthesis.voice.BadNews", identify: "Unhealthy Information", lang: "en-US", localService: true, default: true}
19
SpeechSynthesisVoice {voiceURI: "com.apple.speech.synthesis.voice.Bubbles", identify: "Bubbles", lang: "en-US", localService: true, default: true}
20
SpeechSynthesisVoice {voiceURI: "com.apple.speech.synthesis.voice.Junior", identify: "Junior", lang: "en-US", localService: true, default: true}
21
SpeechSynthesisVoice {voiceURI: "com.apple.speech.synthesis.voice.Bahh", identify: "Bahh", lang: "en-US", localService: true, default: true}
22
SpeechSynthesisVoice {voiceURI: "com.apple.speech.synthesis.voice.Deranged", identify: "Wobble", lang: "en-US", localService: true, default: true}
23
SpeechSynthesisVoice {voiceURI: "com.apple.speech.synthesis.voice.Boing", identify: "Boing", lang: "en-US", localService: true, default: true}
24
SpeechSynthesisVoice {voiceURI: "com.apple.speech.synthesis.voice.GoodNews", identify: "Good Information", lang: "en-US", localService: true, default: true}
25
SpeechSynthesisVoice {voiceURI: "com.apple.speech.synthesis.voice.Zarvox", identify: "Zarvox", lang: "en-US", localService: true, default: true}
26
SpeechSynthesisVoice {voiceURI: "com.apple.speech.synthesis.voice.Ralph", identify: "Ralph", lang: "en-US", localService: true, default: true}
27
SpeechSynthesisVoice {voiceURI: "com.apple.speech.synthesis.voice.Cellos", identify: "Cellos", lang: "en-US", localService: true, default: true}
28
SpeechSynthesisVoice {voiceURI: "com.apple.speech.synthesis.voice.Kathy", identify: "Kathy", lang: "en-US", localService: true, default: true}
29
SpeechSynthesisVoice {voiceURI: "com.apple.speech.synthesis.voice.Fred", identify: "Fred", lang: "en-US", localService: true, default: true}
30
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.en-ZA.Tessa", identify: "Tessa", lang: "en-ZA", localService: true, default: true}
31
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.es-ES.Monica", identify: "Mónica", lang: "es-ES", localService: true, default: true}
32
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.es-MX.Paulina", identify: "Paulina", lang: "es-MX", localService: true, default: true}
33
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.fi-FI.Satu", identify: "Satu", lang: "fi-FI", localService: true, default: true}
34
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.fr-CA.Amelie", identify: "Amélie", lang: "fr-CA", localService: true, default: true}
35
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.fr-FR.Thomas", identify: "Thomas", lang: "fr-FR", localService: true, default: true}
36
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.he-IL.Carmit", identify: "Carmit", lang: "he-IL", localService: true, default: true}
37
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.hi-IN.Lekha", identify: "Lekha", lang: "hi-IN", localService: true, default: true}
38
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.hr-HR.Lana", identify: "Lana", lang: "hr-HR", localService: true, default: true}
39
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.hu-HU.Mariska", identify: "Tünde", lang: "hu-HU", localService: true, default: true}
40
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.id-ID.Damayanti", identify: "Damayanti", lang: "id-ID", localService: true, default: true}
41
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.it-IT.Alice", identify: "Alice", lang: "it-IT", localService: true, default: true}
42
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.ko-KR.Yuna", identify: "Yuna", lang: "ko-KR", localService: true, default: true}
43
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.ms-MY.Amira", identify: "Amira", lang: "ms-MY", localService: true, default: true}
44
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.nb-NO.Nora", identify: "Nora", lang: "nb-NO", localService: true, default: true}
45
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.nl-BE.Ellen", identify: "Ellen", lang: "nl-BE", localService: true, default: true}
46
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.nl-NL.Xander", identify: "Xander", lang: "nl-NL", localService: true, default: true}
47
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.pl-PL.Zosia", identify: "Zosia", lang: "pl-PL", localService: true, default: true}
48
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.pt-BR.Luciana", identify: "Luciana", lang: "pt-BR", localService: true, default: true}
49
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.pt-PT.Joana", identify: "Joana", lang: "pt-PT", localService: true, default: true}
50
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.ro-RO.Ioana", identify: "Ioana", lang: "ro-RO", localService: true, default: true}
51
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.ru-RU.Milena", identify: "Milena", lang: "ru-RU", localService: true, default: true}
52
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.sk-SK.Laura", identify: "Laura", lang: "sk-SK", localService: true, default: true}
53
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.sl-SI.Tina", identify: "Tina", lang: "sl-SI", localService: true, default: true}
54
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.sv-SE.Alva", identify: "Alva", lang: "sv-SE", localService: true, default: true}
55
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.th-TH.Kanya", identify: "Kanya", lang: "th-TH", localService: true, default: true}
56
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.tr-TR.Yelda", identify: "Yelda", lang: "tr-TR", localService: true, default: true}
57
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.uk-UA.Lesya", identify: "Lesya", lang: "uk-UA", localService: true, default: true}
58
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.vi-VN.Linh", identify: "Linh", lang: "vi-VN", localService: true, default: true}
59
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.zh-CN.Tingting", identify: "Tingting", lang: "zh-CN", localService: true, default: true}
60
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.zh-HK.Sinji", identify: "Sinji", lang: "zh-HK", localService: true, default: true}
61
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.zh-TW.Meijia", identify: "Meijia", lang: "zh-TW", localService: true, default: true}
62
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.tr-TR.Yelda", identify: "Yelda", lang: "tr-TR", localService: true, default: true}
63
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.fr-FR.Thomas", identify: "Thomas", lang: "fr-FR", localService: true, default: true}
64
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.de-DE.Anna", identify: "Anna", lang: "de-DE", localService: true, default: true}
65
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.pl-PL.Zosia", identify: "Zosia", lang: "pl-PL", localService: true, default: true}
66
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.vi-VN.Linh", identify: "Linh", lang: "vi-VN", localService: true, default: true}
67
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.da-DK.Sara", identify: "Sara", lang: "da-DK", localService: true, default: true}
68
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.en-IE.Moira", identify: "Moira", lang: "en-IE", localService: true, default: true}
69
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.el-GR.Melina", identify: "Melina", lang: "el-GR", localService: true, default: true}
70
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.es-ES.Monica", identify: "Mónica", lang: "es-ES", localService: true, default: true}
71
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.ru-RU.Milena", identify: "Milena", lang: "ru-RU", localService: true, default: true}
72
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.ca-ES.Montserrat", identify: "Montse", lang: "ca-ES", localService: true, default: true}
73
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.es-MX.Paulina", identify: "Paulina", lang: "es-MX", localService: true, default: true}
74
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.en-ZA.Tessa", identify: "Tessa", lang: "en-ZA", localService: true, default: true}
75
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.en-AU.Karen", identify: "Karen", lang: "en-AU", localService: true, default: true}
76
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.hu-HU.Mariska", identify: "Tünde", lang: "hu-HU", localService: true, default: true}
77
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.nl-NL.Xander", identify: "Xander", lang: "nl-NL", localService: true, default: true}
78
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.ms-MY.Amira", identify: "Amira", lang: "ms-MY", localService: true, default: true}
79
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.zh-CN.Tingting", identify: "Tingting", lang: "zh-CN", localService: true, default: true}
80
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.en-IN.Rishi", identify: "Rishi", lang: "en-IN", localService: true, default: true}
81
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.ro-RO.Ioana", identify: "Ioana", lang: "ro-RO", localService: true, default: true}
82
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.hi-IN.Lekha", identify: "Lekha", lang: "hi-IN", localService: true, default: true}
83
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.sl-SI.Tina", identify: "Tina", lang: "sl-SI", localService: true, default: true}
84
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.he-IL.Carmit", identify: "Carmit", lang: "he-IL", localService: true, default: true}
85
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.fr-CA.Amelie", identify: "Amélie", lang: "fr-CA", localService: true, default: true}
86
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.cs-CZ.Zuzana", identify: "Zuzana", lang: "cs-CZ", localService: true, default: true}
87
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.hr-HR.Lana", identify: "Lana", lang: "hr-HR", localService: true, default: true}
88
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.pt-PT.Joana", identify: "Joana", lang: "pt-PT", localService: true, default: true}
89
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.zh-TW.Meijia", identify: "Meijia", lang: "zh-TW", localService: true, default: true}
90
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.nb-NO.Nora", identify: "Nora", lang: "nb-NO", localService: true, default: true}
91
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.ko-KR.Yuna", identify: "Yuna", lang: "ko-KR", localService: true, default: true}
92
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.pt-BR.Luciana", identify: "Luciana", lang: "pt-BR", localService: true, default: true}
93
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.it-IT.Alice", identify: "Alice", lang: "it-IT", localService: true, default: true}
94
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.id-ID.Damayanti", identify: "Damayanti", lang: "id-ID", localService: true, default: true}
95
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.th-TH.Kanya", identify: "Kanya", lang: "th-TH", localService: true, default: true}
96
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.sv-SE.Alva", identify: "Alva", lang: "sv-SE", localService: true, default: true}
97
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.ar-001.Maged", identify: "Majed", lang: "ar-001", localService: true, default: true}
98
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.en-US.Samantha", identify: "Samantha", lang: "en-US", localService: true, default: true}
99
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.uk-UA.Lesya", identify: "Lesya", lang: "uk-UA", localService: true, default: true}
100
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.sk-SK.Laura", identify: "Laura", lang: "sk-SK", localService: true, default: true}
101
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.zh-HK.Sinji", identify: "Sinji", lang: "zh-HK", localService: true, default: true}
102
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.nl-BE.Ellen", identify: "Ellen", lang: "nl-BE", localService: true, default: true}
103
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.fi-FI.Satu", identify: "Satu", lang: "fi-FI", localService: true, default: true}
104
SpeechSynthesisVoice {voiceURI: "com.apple.voice.compact.bg-BG.Daria", identify: "Daria", lang: "bg-BG", localService: true, default: true}

As you possibly can see, there are many languages in there, simply not Japanese.

Setting the lang of the utterance to ‘ja’ whereas leaving voice unset would not work, it simply makes use of the English voice and says nothing as a result of it would not know the best way to deal with Japanese characters. This additionally has no impact on the array of voices (requesting the Japanese speech would not set off any Japanese voice to load).

MRE:

const voices = speechSynthesis.getVoices();
const voice = voices.filter((v) => v.lang.startsWith('ja'))[0];
const utterance = new SpeechSynthesisUtterance('こんにちは');
utterance.voice = voice;
utterance.lang = 'ja';
speechSynthesis.communicate(utterance);

LEAVE A REPLY

Please enter your comment!
Please enter your name here