/
index.md
61 lines (43 loc) · 1.8 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
---
title: "SpeechSynthesisUtterance: pitch プロパティ"
short-title: pitch
slug: Web/API/SpeechSynthesisUtterance/pitch
l10n:
sourceCommit: 101ffc9479db6aaa530f2aac3992734dd97d1b86
---
{{APIRef("Web Speech API")}}
**`pitch`** は {{domxref("SpeechSynthesisUtterance")}} インターフェイスのプロパティで、発話が行われるピッチ(音程)を取得および設定します。
未設定の場合、既定値の 1 が使用されます。
## 値
浮動小数点数で音程値を表します。
0 (最低)から 2 (最高)の範囲で指定でき、1 が現在のプラットフォームまたは音声の既定値です。音声合成エンジンや音声によっては、最小レートと最大レートがさらに制約される場合があります。
[SSML](https://www.w3.org/TR/speech-synthesis/) を使用している場合、この値はマークアップ内の[韻律タグ](https://www.w3.org/TR/speech-synthesis/#S3.2.4)によって上書きされます。
## 例
```js
const synth = window.speechSynthesis;
const inputForm = document.querySelector("form");
const inputTxt = document.querySelector("input");
const voiceSelect = document.querySelector("select");
const voices = synth.getVoices();
// ...
inputForm.onsubmit = (event) => {
event.preventDefault();
const utterThis = new SpeechSynthesisUtterance(inputTxt.value);
const selectedOption =
voiceSelect.selectedOptions[0].getAttribute("data-name");
for (let i = 0; i < voices.length; i++) {
if (voices[i].name === selectedOption) {
utterThis.voice = voices[i];
}
}
utterThis.pitch = 1.5;
synth.speak(utterThis);
inputTxt.blur();
};
```
## 仕様書
{{Specifications}}
## ブラウザーの互換性
{{Compat}}
## 関連情報
- [ウェブ音声 API](/ja/docs/Web/API/Web_Speech_API)