summaryrefslogtreecommitdiffstats
path: root/src/tts/qvoice.cpp
blob: b3ec430a48e612897ff4e200e16091ace3fcd306 (plain)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
/****************************************************************************
**
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Speech module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:COMM$
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** $QT_END_LICENSE$
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
**
****************************************************************************/



#include "qvoice.h"
#include "qvoice_p.h"
#include "qtexttospeech.h"

QT_BEGIN_NAMESPACE

/*!
  \class QVoice
  \brief The QVoice class allows to set and retrieve values of a particular voice.
  \inmodule QtSpeech
*/

/*!
    \enum QVoice::Age

    The age of a voice.

    \value Child    Voice of a child
    \value Teenager Voice of a teenager
    \value Adult    Voice of an adult
    \value Senior   Voice of a senior
    \value Other    Voice of unknown age
*/

/*!
    \enum QVoice::Gender

    The gender of a voice.

    \value Male    Voice of a male
    \value Female  Voice of a female
    \value Unknown Voice of unknown gender
*/

QVoice::QVoice()
{
    d = new QVoicePrivate();
}

QVoice::QVoice(const QVoice &other)
    :d(other.d)
{
}

QVoice::QVoice(const QString &name, Gender gender, Age age, const QVariant &data)
    :d(new QVoicePrivate(name, gender, age, data))
{
}

QVoice::~QVoice()
{
}

void QVoice::operator=(const QVoice &other)
{
    d->name = other.d->name;
    d->gender = other.d->gender;
    d->age = other.d->age;
    d->data = other.d->data;
}

/*!
    Compares the \l name, \l gender, and \l age of this voice with \a other.
    Returns \c true if all of them match.
*/
bool QVoice::operator==(const QVoice &other)
{
    if (d->name != other.d->name ||
        d->gender != other.d->gender ||
        d->age != other.d->age ||
        d->data != other.d->data)
        return false;
    return true;
}

/*!
    Compares the \l name, \l gender, and \l age of this voice with \a other.
    Returns \c true if they are not identical.
*/
bool QVoice::operator!=(const QVoice &other)
{
    return !operator==(other);
}

/*!
   Assign a \a name to a voice.
*/
void QVoice::setName(const QString &name)
{
    d->name = name;
}

/*!
   Assign a \a gender to a voice.
*/
void QVoice::setGender(Gender gender)
{
    d->gender = gender;
}

/*!
   Set the \a age property.
*/
void QVoice::setAge(Age age)
{
    d->age = age;
}

void QVoice::setData(const QVariant &data)
{
    d->data = data;
}

/*!
   Returns the name of a voice.
*/
QString QVoice::name() const
{
    return d->name;
}

/*!
   Returns the age of a voice.
*/
QVoice::Age QVoice::age() const
{
    return d->age;
}

/*!
   Returns the gender of a voice.
*/
QVoice::Gender QVoice::gender() const
{
    return d->gender;
}

QVariant QVoice::data() const
{
    return d->data;
}

/*!̈́
   Returns the \a gender name of a voice.
*/
QString QVoice::genderName(QVoice::Gender gender)
{
    QString retval;
    switch (gender) {
        case QVoice::Male:
            retval = QTextToSpeech::tr("Male", "Gender of a voice");
            break;
        case QVoice::Female:
            retval = QTextToSpeech::tr("Female", "Gender of a voice");
            break;
        case QVoice::Unknown:
        default:
            retval = QTextToSpeech::tr("Unknown Gender", "Voice gender is unknown");
            break;
    }
    return retval;
}

/*!
   Returns a string representing the \a age class of a voice.
*/
QString QVoice::ageName(QVoice::Age age)
{
    QString retval;
    switch (age) {
        case QVoice::Child:
            retval = QTextToSpeech::tr("Child", "Age of a voice");
            break;
        case QVoice::Teenager:
            retval = QTextToSpeech::tr("Teenager", "Age of a voice");
            break;
        case QVoice::Adult:
            retval = QTextToSpeech::tr("Adult", "Age of a voice");
            break;
        case QVoice::Senior:
            retval = QTextToSpeech::tr("Senior", "Age of a voice");
            break;
        case QVoice::Other:
        default:
            retval = QTextToSpeech::tr("Other Age", "Unknown age of a voice");
            break;
    }
    return retval;
}

QT_END_NAMESPACE