summaryrefslogtreecommitdiffstats
path: root/utils/rbutilqt/test/stubs/stubs-talkgenerator.cpp
blob: 295dc81a78131283d88b2f2834e60265692140be (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
/***************************************************************************
 *             __________               __   ___.
 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
 *                     \/            \/     \/    \/            \/
 *
 * Copyright (C) 2022 Dominik Riebeling
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 * KIND, either express or implied.
 *
 ****************************************************************************/

// Stubs for TalkGenerator unit test.

#include "rbsettings.h"
#include "ttsbase.h"
#include "encoderbase.h"
#include "playerbuildinfo.h"

extern "C" int wavtrim(char* filename, int maxsilence, char* errstring, int errsize)
{
    (void)filename;
    (void)maxsilence;
    (void)errstring;
    (void)errsize;
    return 0;
}

static QMap<RbSettings::UserSettings, QVariant> stubUserSettings;

QVariant RbSettings::value(UserSettings setting)
{
    switch (setting)
    {
        case RbSettings::Tts:
            return QString("espeak");
        default:
            return QVariant();
    }
}

class TTSFakeEspeak : public TTSBase
{
    Q_OBJECT
public:
    TTSFakeEspeak(QObject *parent): TTSBase(parent) {}
    virtual bool start(QString *errStr) { (void)errStr; return true; }
    virtual bool stop() { return true; }
    virtual TTSStatus voice(QString text, QString wavfile, QString *errStr)
    { (void)text; (void)wavfile; (void)errStr; return NoError; }
    virtual QString voiceVendor() { return QString("DummyVendor"); }
    virtual bool configOk() { return true; }
    virtual void generateSettings() {}
    virtual void saveSettings() {}
    virtual Capabilities capabilities() { return None; }
};

TTSBase::TTSBase(QObject* parent) : EncTtsSettingInterface(parent)
{
}

TTSStatus TTSBase::voice(QString /*text*/, QString /*wavfile*/, QString* /*errStr*/)
{
    return NoError;
}

TTSBase* TTSBase::getTTS(QObject* parent, QString /*ttsName*/)
{
    return new TTSFakeEspeak(parent);
}

EncoderBase* EncoderBase::getEncoder(QObject*, QString)
{
    return nullptr;
}

QVariant PlayerBuildInfo::value(PlayerBuildInfo::DeviceInfo /*item*/, QString /*target*/)
{
    return QVariant();
}

PlayerBuildInfo* PlayerBuildInfo::infoInstance = nullptr;

PlayerBuildInfo::PlayerBuildInfo()
{
}

PlayerBuildInfo* PlayerBuildInfo::instance()
{
    if (infoInstance == nullptr) {
        infoInstance = new PlayerBuildInfo();
    }
    return infoInstance;
}

#include "stubs-talkgenerator.moc"