2 * Copyright (c) 2010-2024 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;
15 import java.util.Locale;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.core.voice.Voice;
19 import org.openhab.voice.googletts.internal.dto.SsmlVoiceGender;
22 * Implementation of the Voice interface for Google Cloud TTS Service.
24 * @author Gabor Bicskei - Initial contribution
27 public class GoogleTTSVoice implements Voice {
32 private final Locale locale;
37 private final String label;
42 private final String ssmlGender;
45 * Constructs a Google Cloud TTS Voice for the passed data
47 * @param locale The Locale of the voice
48 * @param label The label of the voice
49 * @param ssmlGender Voice gender
51 GoogleTTSVoice(Locale locale, String label, String ssmlGender) {
53 this.ssmlGender = ssmlGender;
58 * Globally unique identifier of the voice.
60 * @return A String uniquely identifying the voice globally
63 public String getUID() {
64 return "googletts:" + getTechnicalName();
68 * Technical name of the voice.
70 * @return A String voice technical name
72 String getTechnicalName() {
73 return label.replaceAll("[^a-zA-Z0-9_]", "");
77 * The voice label, used for GUI's or VUI's
79 * @return The voice label, may not be globally unique
82 public String getLabel() {
90 public Locale getLocale() {
97 * @return {@link SsmlVoiceGender} enum name.
99 String getSsmlGender() {