2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.voice.googletts.internal.dto;
16 * The configuration of the synthesized audio.
18 * @author Wouter Born - Initial contribution
20 public class AudioConfig {
23 * Required. The format of the requested audio byte stream.
25 private AudioEncoding audioEncoding;
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.
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.
39 private Long sampleRateHertz;
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.
46 private Double speakingRate;
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.
55 private Double volumeGainDb;
57 public AudioConfig() {
60 public AudioConfig(AudioEncoding audioEncoding, Double pitch, Double speakingRate, Double volumeGainDb) {
61 this(audioEncoding, pitch, null, speakingRate, volumeGainDb);
64 public AudioConfig(AudioEncoding audioEncoding, Double pitch, Long sampleRateHertz, Double speakingRate,
65 Double volumeGainDb) {
66 this.audioEncoding = audioEncoding;
68 this.sampleRateHertz = sampleRateHertz;
69 this.speakingRate = speakingRate;
70 this.volumeGainDb = volumeGainDb;
73 public AudioEncoding getAudioEncoding() {
77 public Double getPitch() {
81 public Long getSampleRateHertz() {
82 return sampleRateHertz;
85 public Double getSpeakingRate() {
89 public Double getVolumeGainDb() {
93 public void setAudioEncoding(AudioEncoding audioEncoding) {
94 this.audioEncoding = audioEncoding;
97 public void setPitch(Double pitch) {
101 public void setSampleRateHertz(Long sampleRateHertz) {
102 this.sampleRateHertz = sampleRateHertz;
105 public void setSpeakingRate(Double speakingRate) {
106 this.speakingRate = speakingRate;
109 public void setVolumeGainDb(Double volumeGainDb) {
110 this.volumeGainDb = volumeGainDb;