]> git.basschouten.com Git - openhab-addons.git/blob
5e3f91baef1fe7610121326ce501b792d0cd5904
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 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.marytts.internal;
14
15 import java.util.Locale;
16
17 import org.openhab.core.voice.Voice;
18
19 /**
20  * Implementation of the Voice interface for MaryTTS
21  *
22  * @author Kelly Davis - Initial contribution and API
23  * @author Kai Kreuzer - Refactored to updated APIs and moved to openHAB
24  */
25 public class MaryTTSVoice implements Voice {
26
27     /**
28      * Voice locale
29      */
30     private final Locale locale;
31
32     /**
33      * Voice label
34      */
35     private final String label;
36
37     /**
38      * Constructs a MaryTTS Voice for the passed data
39      *
40      * @param locale The Locale of the voice
41      * @param label The label of the voice
42      */
43     public MaryTTSVoice(Locale locale, String label) {
44         this.locale = locale;
45         this.label = label;
46     }
47
48     /**
49      * Globally unique identifier of the voice.
50      *
51      * @return A String uniquely identifying the voice globally
52      */
53     @Override
54     public String getUID() {
55         return "marytts:" + label.replaceAll("[^a-zA-Z0-9_]", "");
56     }
57
58     /**
59      * The voice label, used for GUI's or VUI's
60      *
61      * @return The voice label, may not be globally unique
62      */
63     @Override
64     public String getLabel() {
65         return label;
66     }
67
68     /**
69      * {@inheritDoc}
70      */
71     @Override
72     public Locale getLocale() {
73         return locale;
74     }
75 }