質問編集履歴

3

質問内容は変更ありません。codeボタンを使って、プログラムを記入しました。

2018/12/19 06:28

投稿

kimukimu009
kimukimu009

スコア33

test CHANGED
File without changes
test CHANGED
@@ -1,12 +1,4 @@
1
- ```**__~~### ```ここに言語を入力
2
-
3
- ここに言語を入力
4
-
5
- ```~~__**
6
-
7
- コード
8
-
9
- ```■やりたいこと
1
+ ■やりたいこと
10
2
 
11
3
  ボタンをクリックすると、各言語の音声合成を行い、読み上げる。
12
4
 
@@ -28,11 +20,7 @@
28
20
 
29
21
 
30
22
 
31
- ```**ここに言語を入力**
32
-
33
- コード
23
+ ```
34
-
35
- ```----------------------プロブラム----------------------
36
24
 
37
25
  <!DOCTYPE html>
38
26
 
@@ -274,4 +262,4 @@
274
262
 
275
263
  </html>
276
264
 
277
- ----------------------プロブラム----------------------
265
+ ```

2

2018/12/19 06:28

投稿

kimukimu009
kimukimu009

スコア33

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,12 @@
1
+ ```**__~~### ```ここに言語を入力
2
+
3
+ ここに言語を入力
4
+
5
+ ```~~__**
6
+
7
+ コード
8
+
1
- ■やりたいこと
9
+ ```■やりたいこと
2
10
 
3
11
  ボタンをクリックすると、各言語の音声合成を行い、読み上げる。
4
12
 
@@ -20,246 +28,250 @@
20
28
 
21
29
 
22
30
 
31
+ ```**ここに言語を入力**
32
+
33
+ コード
34
+
35
+ ```----------------------プロブラム----------------------
36
+
37
+ <!DOCTYPE html>
38
+
39
+ <html>
40
+
41
+
42
+
43
+ <head>
44
+
45
+ <meta charset="UTF-8">
46
+
47
+ <title>TEST</title>
48
+
49
+
50
+
51
+
52
+
53
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
54
+
55
+ <script type = "text/javascript">
56
+
57
+
58
+
59
+ function functionName()
60
+
61
+ {
62
+
63
+ var select1 = document.forms.formName.selectName1; //変数select1を宣言
64
+
65
+ var select2 = document.forms.formName.selectName2; //変数select2を宣言
66
+
67
+ var textin = '';
68
+
69
+
70
+
71
+ select2.options.length = 0; // 選択肢の数がそれぞれに異なる場合、これが重要
72
+
73
+
74
+
75
+ if (select1.options[select1.selectedIndex].value == "en-US")
76
+
77
+ {
78
+
79
+ select2.options[0] = new Option("I came from America.");
80
+
81
+ textin = 'I came from America.';
82
+
83
+ }
84
+
85
+
86
+
87
+ else if (select1.options[select1.selectedIndex].value == "en-GB")
88
+
89
+ {
90
+
91
+ select2.options[0] = new Option("I came from England");
92
+
93
+ textin = 'I came from England';
94
+
95
+ }
96
+
97
+
98
+
99
+ else if (select1.options[select1.selectedIndex].value == "ja-JP")
100
+
101
+ {
102
+
103
+ select2.options[0] = new Option("私は日本から来ました");
104
+
105
+ textin = '私は日本から来ました';
106
+
107
+ }
108
+
109
+ document.getElementById('start').innerText = textin;
110
+
111
+
112
+
113
+ }
114
+
115
+ </script>
116
+
117
+
118
+
119
+
120
+
121
+ <script>
122
+
123
+ $(function() {
124
+
125
+ // unsupported.
126
+
127
+ if (!'SpeechSynthesisUtterance' in window) {
128
+
129
+ alert('Speech synthesis(音声合成) APIには未対応です.');
130
+
131
+ return;
132
+
133
+ }
134
+
135
+
136
+
137
+ // 発話機能をインスタンス化
138
+
139
+ var msg = new SpeechSynthesisUtterance();
140
+
141
+ var voices = window.speechSynthesis.getVoices();
142
+
143
+
144
+
145
+ $('#start').on('click',function() {
146
+
147
+
148
+
149
+ // 以下オプション設定(日本語は効かないもよう。。)
150
+
151
+ msg.voice = voices[7]; // 7:Google 日本人 ja-JP ※他は英語のみ(次項参照)
152
+
153
+ msg.volume = 1.0; // 音量 min 0 ~ max 1
154
+
155
+ msg.rate = 1.0; // 速度 min 0 ~ max 10
156
+
157
+ msg.pitch = 1.0; // 音程 min 0 ~ max 2
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+ msg.text = $('#txt').val(); // 喋る内容
166
+
167
+ msg.lang = $('#language').val(); // en-US or ja-JP
168
+
169
+
170
+
171
+ // msg.lang = 'ja-JP'; // en-US or ja-JP
172
+
173
+ // msg.lang = 'en-US'; // en-US or ja-JP
174
+
175
+
176
+
177
+ // 発話実行
178
+
179
+ speechSynthesis.speak(msg);
180
+
181
+
182
+
183
+
184
+
185
+ // 終了時の処理
186
+
187
+ msg.onend = function (event) {
188
+
189
+ console.log('喋った時間:' + event.elapsedTime + 's');
190
+
191
+ start()
192
+
193
+ }
194
+
195
+
196
+
197
+ });
198
+
199
+ });
200
+
201
+ </script>
202
+
203
+
204
+
205
+
206
+
207
+ <script>
208
+
209
+ function Write() {
210
+
211
+ var textin = '';
212
+
213
+ textin = 'そうですか';
214
+
215
+  document.getElementById('soudesuka').innerText = textin;
216
+
217
+ }
218
+
219
+ </script>
220
+
221
+
222
+
223
+
224
+
225
+ </head>
226
+
227
+
228
+
229
+ <body>
230
+
231
+
232
+
233
+ <form name="formName">
234
+
235
+ <div class="cp_ipselect cp_sl05">
236
+
237
+ <select name = "selectName1" id="language" onChange="functionName()">
238
+
239
+ <option value = "en-US" selected>English(USA)</option>
240
+
241
+ <option value = "en-GB">English(UK)</option>
242
+
243
+ <option value = "ja-JP">日本語</option>
244
+
245
+ </select>
246
+
247
+ </div>
248
+
249
+ <div class="select-box01">
250
+
251
+ <select id="txt" name = "selectName2">
252
+
253
+ </select>
254
+
255
+ </div>
256
+
257
+ </form>
258
+
259
+ <button id="start" onclick="Write()"></button><br><br>
260
+
261
+
262
+
263
+ <textarea id="soudesuka" type="text"></textarea>
264
+
265
+
266
+
267
+
268
+
269
+
270
+
271
+ </body>
272
+
273
+
274
+
275
+ </html>
276
+
23
277
  ----------------------プロブラム----------------------
24
-
25
- <!DOCTYPE html>
26
-
27
- <html>
28
-
29
-
30
-
31
- <head>
32
-
33
- <meta charset="UTF-8">
34
-
35
- <title>TEST</title>
36
-
37
-
38
-
39
-
40
-
41
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
42
-
43
- <script type = "text/javascript">
44
-
45
-
46
-
47
- function functionName()
48
-
49
- {
50
-
51
- var select1 = document.forms.formName.selectName1; //変数select1を宣言
52
-
53
- var select2 = document.forms.formName.selectName2; //変数select2を宣言
54
-
55
- var textin = '';
56
-
57
-
58
-
59
- select2.options.length = 0; // 選択肢の数がそれぞれに異なる場合、これが重要
60
-
61
-
62
-
63
- if (select1.options[select1.selectedIndex].value == "en-US")
64
-
65
- {
66
-
67
- select2.options[0] = new Option("I came from America.");
68
-
69
- textin = 'I came from America.';
70
-
71
- }
72
-
73
-
74
-
75
- else if (select1.options[select1.selectedIndex].value == "en-GB")
76
-
77
- {
78
-
79
- select2.options[0] = new Option("I came from England");
80
-
81
- textin = 'I came from England';
82
-
83
- }
84
-
85
-
86
-
87
- else if (select1.options[select1.selectedIndex].value == "ja-JP")
88
-
89
- {
90
-
91
- select2.options[0] = new Option("私は日本から来ました");
92
-
93
- textin = '私は日本から来ました';
94
-
95
- }
96
-
97
- document.getElementById('start').innerText = textin;
98
-
99
-
100
-
101
- }
102
-
103
- </script>
104
-
105
-
106
-
107
-
108
-
109
- <script>
110
-
111
- $(function() {
112
-
113
- // unsupported.
114
-
115
- if (!'SpeechSynthesisUtterance' in window) {
116
-
117
- alert('Speech synthesis(音声合成) APIには未対応です.');
118
-
119
- return;
120
-
121
- }
122
-
123
-
124
-
125
- // 発話機能をインスタンス化
126
-
127
- var msg = new SpeechSynthesisUtterance();
128
-
129
- var voices = window.speechSynthesis.getVoices();
130
-
131
-
132
-
133
- $('#start').on('click',function() {
134
-
135
-
136
-
137
- // 以下オプション設定(日本語は効かないもよう。。)
138
-
139
- msg.voice = voices[7]; // 7:Google 日本人 ja-JP ※他は英語のみ(次項参照)
140
-
141
- msg.volume = 1.0; // 音量 min 0 ~ max 1
142
-
143
- msg.rate = 1.0; // 速度 min 0 ~ max 10
144
-
145
- msg.pitch = 1.0; // 音程 min 0 ~ max 2
146
-
147
-
148
-
149
-
150
-
151
-
152
-
153
- msg.text = $('#txt').val(); // 喋る内容
154
-
155
- msg.lang = $('#language').val(); // en-US or ja-JP
156
-
157
-
158
-
159
- // msg.lang = 'ja-JP'; // en-US or ja-JP
160
-
161
- // msg.lang = 'en-US'; // en-US or ja-JP
162
-
163
-
164
-
165
- // 発話実行
166
-
167
- speechSynthesis.speak(msg);
168
-
169
-
170
-
171
-
172
-
173
- // 終了時の処理
174
-
175
- msg.onend = function (event) {
176
-
177
- console.log('喋った時間:' + event.elapsedTime + 's');
178
-
179
- start()
180
-
181
- }
182
-
183
-
184
-
185
- });
186
-
187
- });
188
-
189
- </script>
190
-
191
-
192
-
193
-
194
-
195
- <script>
196
-
197
- function Write() {
198
-
199
- var textin = '';
200
-
201
- textin = 'そうですか';
202
-
203
-  document.getElementById('soudesuka').innerText = textin;
204
-
205
- }
206
-
207
- </script>
208
-
209
-
210
-
211
-
212
-
213
- </head>
214
-
215
-
216
-
217
- <body>
218
-
219
-
220
-
221
- <form name="formName">
222
-
223
- <div class="cp_ipselect cp_sl05">
224
-
225
- <select name = "selectName1" id="language" onChange="functionName()">
226
-
227
- <option value = "en-US" selected>English(USA)</option>
228
-
229
- <option value = "en-GB">English(UK)</option>
230
-
231
- <option value = "ja-JP">日本語</option>
232
-
233
- </select>
234
-
235
- </div>
236
-
237
- <div class="select-box01">
238
-
239
- <select id="txt" name = "selectName2">
240
-
241
- </select>
242
-
243
- </div>
244
-
245
- </form>
246
-
247
- <button id="start" onclick="Write()"></button><br><br>
248
-
249
-
250
-
251
- <textarea id="soudesuka" type="text"></textarea>
252
-
253
-
254
-
255
-
256
-
257
-
258
-
259
- </body>
260
-
261
-
262
-
263
- </html>
264
-
265
- ----------------------プロブラム----------------------

1

2018/12/19 05:37

投稿

kimukimu009
kimukimu009

スコア33

test CHANGED
File without changes
test CHANGED
File without changes