Skip to content

Commit

Permalink
Add random phrase, clear text button, word, char count
Browse files Browse the repository at this point in the history
  • Loading branch information
ZDisket committed Mar 18, 2022
1 parent baa092f commit 41f21fe
Show file tree
Hide file tree
Showing 11 changed files with 223 additions and 4 deletions.
2 changes: 1 addition & 1 deletion TensorVox.pro
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ RESOURCES += \

win32:RC_ICONS += winicon.ico

VERSION = 0.8.9.0
VERSION = 0.9.0.0
CONFIG += force_debug_info

QMAKE_CXXFLAGS += /std:c++17 /utf-8 -DPSAPI_VERSION=1
Expand Down
17 changes: 16 additions & 1 deletion TextTokenizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,22 @@ vector<string> TextTokenizer::ExpandNumbers(const std::vector<std::string>& Spac

std::replace(ModTk.begin(),ModTk.end(),'-',' ');

RetVec.push_back(ModTk);
// If the number has spaces we must sep again and add one by one otherwise all the words are merged together due to the
// nature of it
ZStringDelimiter DelSp(ModTk);
DelSp.AddDelimiter(" ");

if (DelSp.szTokens())
{
for (const auto& Ttk : DelSp.GetTokens())
RetVec.push_back(Ttk);

}else{
RetVec.push_back(ModTk);
}





}
Expand Down
107 changes: 106 additions & 1 deletion mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,33 @@
#include "track.h"
#define FwParent ((FramelessWindow*)pDarkFw)
#include <psapi.h>

#include <QTextStream>
#include <random>


// maybe hardcoding the sample sentences is a bad idea?
static const QString RandomTexts[] = {"Drink the water fishy",
"She turned herself into a thorn. It was the funniest shit I've ever seen",
"That was an order! Steiner's attack was an order!",
"There is no attitude that could not find its ultimate justification in the benefits it gives to the whole",
"President Trump met with other leaders at the Group of twenty conference",
"There’s a way to measure the acute emotional intelligence that has never gone out of style",
"Peter Piper picked a peck of pickled peppers. How many pickled peppers did Peter Piper pick?",
"It needs to be about 20 percent cooler",
"Sneed's feed and seed",
"The right to repair electronics refers to proposed government legislation that would allow consumers the ability to repair and modify their own consumer electronic devices",
"Eternal chaos come with chocolate rain, you guys!",
"What fun is there in making sense?",
"And then what she said was scandalous",
"Think of tuna fish as a very fishy fish",
"Still don't trust me",
"Do not compare yourself to others. If you do so, you are insulting yourself",
"Let that child alone",
"If I don't eat rice, the power won't come!",
"Their power is really extraordinary. One thing is sure, they're from another world",
"Now I see. Black human beings dislike the sound of rubbing glass probably the soundwave of the whistle",
"Cats and tomatoes don't mix",
"Six years were enough to fulfill the dreams of centuries. A year to bring our people into the enjoyment of that unity that was the futile aspiration of many generations"};

MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
Expand Down Expand Up @@ -138,6 +164,9 @@ MainWindow::MainWindow(QWidget *parent)
ui->widSpec->Map = SpecMap;
SpecMap->setGradient(Viridis);


ui->lstUtts->addActions({ui->actExWAVSe, ui->actCopySel});

DenBatchSize = 0;
DenDone = 0;
LastExportDir = QCoreApplication::applicationDirPath() + "/Utt.wav";
Expand Down Expand Up @@ -203,6 +232,7 @@ void MainWindow::showEvent(QShowEvent *e)
MainWindow::~MainWindow()
{
on_btnClear_clicked();
LogiLedShutdown();
delete ui;
}

Expand Down Expand Up @@ -1291,6 +1321,28 @@ void MainWindow::SetDict()

}

unsigned MainWindow::OptCountWords(const QString &InText)
{
unsigned RetNum = 0;
bool InSpaceChain = false;
for (const QChar& ch : InText){
if (ch == ' '){
if (!InSpaceChain)
RetNum++;

InSpaceChain = true;

}else{
InSpaceChain = false;
}


}

return RetNum;

}

void MainWindow::on_actionRefresh_model_listing_triggered()
{
PopulateComboBox();
Expand Down Expand Up @@ -1607,10 +1659,16 @@ void MainWindow::on_actionPhonemize_filelist_triggered()

OutputFile.open(QIODevice::WriteOnly | QIODevice::Text);

QTextCodec *codec = QTextCodec::codecForName("UTF-8");

if (InputFile.open(QIODevice::ReadOnly))
{
QTextStream InStream(&InputFile);
QTextStream OutStream(&OutputFile);
InStream.setCodec(codec);
OutStream.setCodec(codec);



while (!InStream.atEnd())
{
Expand Down Expand Up @@ -1806,4 +1864,51 @@ void MainWindow::on_actOpenLastExDir_triggered()
{
QProcess::startDetached(QString("explorer /select, \"%1\"").arg(QDir::toNativeSeparators(LastExportDir)));

}

void MainWindow::on_edtInput_textChanged()
{
const QString Plain = ui->edtInput->toPlainText();

const int NumSplits = Plain.length() / ui->spbSeqLen->value();

ui->lblCharCount->setText(QString::number(Plain.length()) + " C " +
QString::number(OptCountWords(Plain + " ")) + " W " +
QString::number(NumSplits) + " S ");

}

void MainWindow::on_actCopySel_triggered()
{
QClipboard* Clip = QGuiApplication::clipboard();

Clip->setText(ui->lstUtts->currentItem()->text());



}

void MainWindow::on_actExWAVSe_triggered()
{
on_btnExportSel_clicked();


}

void MainWindow::on_btnClearTxt_clicked()
{
ui->edtInput->clear();
}

void MainWindow::on_btnRandom_clicked()
{
std::random_device dev;
std::mt19937 rng(dev());
std::uniform_int_distribution<std::mt19937::result_type> dist6(0,21);

ui->edtInput->setText(RandomTexts[dist6(rng)]);




}
12 changes: 12 additions & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,16 @@ private slots:

void on_actOpenLastExDir_triggered();

void on_edtInput_textChanged();

void on_actCopySel_triggered();

void on_actExWAVSe_triggered();

void on_btnClearTxt_clicked();

void on_btnRandom_clicked();

private:

bool AllowedToPlayAudio();
Expand Down Expand Up @@ -216,6 +226,8 @@ private slots:
int32_t GetID(int32_t InID);
void UpdateLogiLed();
void SetDict();

unsigned OptCountWords(const QString& InText);
void HandleIsMultiSpeaker(size_t inVid);
void HandleIsMultiEmotion(size_t inVid);
bool CanPlayAudio;
Expand Down
84 changes: 83 additions & 1 deletion mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -351,16 +351,81 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<layout class="QHBoxLayout" name="horizontalLayout_14">
<item>
<widget class="QPushButton" name="btnInfer">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Infer (CTRL + Enter)</string>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnClearTxt">
<property name="toolTip">
<string>Clear current text</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="stdres.qrc">
<normaloff>:/res/clear64.png</normaloff>:/res/clear64.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnRandom">
<property name="toolTip">
<string>Random text</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="stdres.qrc">
<normaloff>:/res/random64.png</normaloff>:/res/random64.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblCharCount">
<property name="text">
<string>0 C 0 W 0 S</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11"/>
</item>
</layout>
</item>
<item>
Expand Down Expand Up @@ -607,6 +672,9 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="contextMenuPolicy">
<enum>Qt::ActionsContextMenu</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
Expand Down Expand Up @@ -818,6 +886,20 @@
<string>Open last export directory</string>
</property>
</action>
<action name="actCopySel">
<property name="text">
<string>Copy text</string>
</property>
</action>
<action name="actExWAVSe">
<property name="icon">
<iconset resource="stdres.qrc">
<normaloff>:/res/wav.png</normaloff>:/res/wav.png</iconset>
</property>
<property name="text">
<string>Export to WAV</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
Expand Down
Binary file added res/clear64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/multiwav.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/random64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/speak64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/wav.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions stdres.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@
<file>res/infico.png</file>
<file>res/refresh.png</file>
<file>res/noim.png</file>
<file>res/clear64.png</file>
<file>res/multiwav.png</file>
<file>res/random64.png</file>
<file>res/wav.png</file>
<file>res/speak64.png</file>
</qresource>
</RCC>

0 comments on commit 41f21fe

Please sign in to comment.