]> git.basschouten.com Git - openhab-addons.git/blob
30e84919ee33eca122b29931d7221ec135230266
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.voice.googletts.internal.dto;
14
15 /**
16  * The configuration of the synthesized audio.
17  *
18  * @author Wouter Born - Initial contribution
19  */
20 public class AudioConfig {
21
22     /**
23      * Required. The format of the requested audio byte stream.
24      */
25     private AudioEncoding audioEncoding;
26
27     /**
28      * Optional speaking pitch, in the range [-20.0, 20.0]. 20 means increase 20 semitones from the original pitch. -20
29      * means decrease 20 semitones from the original pitch.
30      */
31     private Double pitch;
32
33     /**
34      * The synthesis sample rate (in hertz) for this audio. Optional. If this is different from the voice's natural
35      * sample rate, then the synthesizer will honor this request by converting to the desired sample rate (which might
36      * result in worse audio quality), unless the specified sample rate is not supported for the encoding chosen, in
37      * which case it will fail the request and return google.rpc.Code.INVALID_ARGUMENT.
38      */
39     private Long sampleRateHertz;
40
41     /**
42      * Optional speaking rate/speed, in the range [0.25, 4.0]. 1.0 is the normal native speed supported by the specific
43      * voice. 2.0 is twice as fast, and 0.5 is half as fast. If unset(0.0), defaults to the native 1.0 speed. Any other
44      * values < 0.25 or > 4.0 will return an error.
45      */
46     private Double speakingRate;
47
48     /**
49      * Optional volume gain (in dB) of the normal native volume supported by the specific voice, in the range [-96.0,
50      * 16.0]. If unset, or set to a value of 0.0 (dB), will play at normal native signal amplitude. A value of -6.0 (dB)
51      * will play at approximately half the amplitude of the normal native signal amplitude. A value of +6.0 (dB) will
52      * play at approximately twice the amplitude of the normal native signal amplitude. Strongly recommend not to exceed
53      * +10 (dB) as there's usually no effective increase in loudness for any value greater than that.
54      */
55     private Double volumeGainDb;
56
57     public AudioConfig() {
58     }
59
60     public AudioConfig(AudioEncoding audioEncoding, Double pitch, Double speakingRate, Double volumeGainDb) {
61         this(audioEncoding, pitch, null, speakingRate, volumeGainDb);
62     }
63
64     public AudioConfig(AudioEncoding audioEncoding, Double pitch, Long sampleRateHertz, Double speakingRate,
65             Double volumeGainDb) {
66         this.audioEncoding = audioEncoding;
67         this.pitch = pitch;
68         this.sampleRateHertz = sampleRateHertz;
69         this.speakingRate = speakingRate;
70         this.volumeGainDb = volumeGainDb;
71     }
72
73     public AudioEncoding getAudioEncoding() {
74         return audioEncoding;
75     }
76
77     public Double getPitch() {
78         return pitch;
79     }
80
81     public Long getSampleRateHertz() {
82         return sampleRateHertz;
83     }
84
85     public Double getSpeakingRate() {
86         return speakingRate;
87     }
88
89     public Double getVolumeGainDb() {
90         return volumeGainDb;
91     }
92
93     public void setAudioEncoding(AudioEncoding audioEncoding) {
94         this.audioEncoding = audioEncoding;
95     }
96
97     public void setPitch(Double pitch) {
98         this.pitch = pitch;
99     }
100
101     public void setSampleRateHertz(Long sampleRateHertz) {
102         this.sampleRateHertz = sampleRateHertz;
103     }
104
105     public void setSpeakingRate(Double speakingRate) {
106         this.speakingRate = speakingRate;
107     }
108
109     public void setVolumeGainDb(Double volumeGainDb) {
110         this.volumeGainDb = volumeGainDb;
111     }
112 }