Repository navigation
Expand file tree
/
Copy pathMainWindowGUI.cpp
More file actions
103 lines (86 loc) · 1.9 KB
/
Copy pathMainWindowGUI.cpp
File metadata and controls
103 lines (86 loc) · 1.9 KB
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
#include "MainWindowGUI.h"
void MainWindowGUI::Init()
{
screenWidth = 1280;
screenHeight = 720;
textColor = raylib::Color::LightGray();
window = new raylib::Window(screenWidth, screenHeight, "Echo - Speech To Text");
font = new raylib::Font("./Resources/Fonts/RobotoMono-Regular.ttf");
SetTargetFPS(60);
button1 = Button("Let's Begin", { 100, 40 }, RED, MGRAY, *font);
button2 = Button("Exit", { 100, 40 }, BLUE, MGRAY, *font);
button1.setPosition({ screenWidth / 2, screenHeight / 2 });
button2.setPosition({ screenWidth / 2, screenHeight / 2 + 50 });
}
void MainWindowGUI::StartLoop()
{
while (!window->ShouldClose())
{
HandleEvents();
Draw();
}
}
void MainWindowGUI::Draw()
{
BeginDrawing();
{
window->ClearBackground(MBG);
button1.draw();
button2.draw();
}
EndDrawing();
}
void MainWindowGUI::HandleEvents()
{
//....Hover Effect....//
if (button1.isMouseOver())
{
button1.setBackgroundColor(LIGHTBLUE);
}
else
{
button1.setBackgroundColor(MGRAY);
}
if (button2.isMouseOver())
{
button2.setBackgroundColor(LIGHTBLUE);
}
else
{
button2.setBackgroundColor(MGRAY);
}
//....Event Handlers....//
if (button1.isPressed())
{
std::cout << "Pressed" << std::endl;
// For testing only
if (!isRunning)
{
audio = new Audio();
transcriber = new Transcriber();
audio->StartStream(RealTime);
transcriber->BeginRealTimeTranscription();
isRunning = true;
}
else
{
delete audio;
delete transcriber;
}
}
if (button2.isPressed()) {
std::cout << "Subtitles Button Pressed" << std::endl;
std::vector<float> pcm32fWav;
std::vector<std::vector<float>> pcmf32sWav;
bool stereo = false;
audio = new Audio();
transcriber = new Transcriber();
audio->readPCMFromWav("C:/Users/USER/Downloads/rain.wav", pcm32fWav, pcmf32sWav, stereo);
transcriber->TranscribeFromWav(pcm32fWav, 1);
}
}
void MainWindowGUI::ShutDown()
{
delete window;
delete font;
}