-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfile_paths.py
188 lines (151 loc) · 7.52 KB
/
file_paths.py
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
#!/usr/bin/env python
################################################################################
# commbase-stt-whisper-reactive-p #
# #
# A reactive version of STT ASR (Automatic Speech Recognition) engine. #
# #
# Change History #
# 01/17/2024 Esteban Herrera Original code. #
# Add new history entries as needed. #
# #
# #
################################################################################
################################################################################
################################################################################
# #
# Copyright (c) 2022-present Esteban Herrera C. #
# stv.herrera@gmail.com #
# #
# 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 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program; if not, write to the Free Software #
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #
# file_paths.py
# This file stores functions related to loading and managing file paths
# Requires os.path already imported
# Imports
from config import CONFIG_FILE_DIR, CONFIG_FILE_PATH
def get_chat_log_file():
"""
Retrieves the value of the CHAT_LOG_FILE variable from the configuration
file.
Returns:
str or None: The value of the variable if found, or None if not found.
"""
# Initialize variable
chat_log_file = None
# Open the file and read its contents
with open(CONFIG_FILE_PATH, "r") as f:
for line in f:
# Split the line into variable name and value
variable_name, value = line.strip().split("=")
# Check if the variable we are looking for exists in the line
if variable_name == "CHAT_LOG_FILE":
# Remove the quotes from the value of the variable
chat_log_file = CONFIG_FILE_DIR + "/" + value.strip()[1:-1]
# Check if the variable was found
if chat_log_file is not None:
return chat_log_file
# If the variable was not found, return None
return None
def get_commbase_hardware_command_processing_start_file():
"""
Retrieves the value of the COMMBASE_HARDWARE_COMMAND_PROCESSING_START_FILE
variable from the configuration file.
Returns:
str or None: The value of the variable if found, or None if not found.
"""
# Initialize variable
processing_start_file = None
# Open the file and read its contents
with open(CONFIG_FILE_PATH, "r") as f:
for line in f:
# Split the line into variable name and value
variable_name, value = line.strip().split("=")
# Check if the variable we are looking for exists in the line
if variable_name == "COMMBASE_HARDWARE_COMMAND_PROCESSING_START_FILE":
# Remove the quotes from the value of the variable
processing_start_file = CONFIG_FILE_DIR + value.strip()[1:-1]
# Check if the variable was found
if processing_start_file is not None:
return processing_start_file
# If the variable was not found, return None
return None
def get_commbase_hardware_command_processing_stop_file():
"""
Retrieves the value of the COMMBASE_HARDWARE_COMMAND_PROCESSING_STOP_FILE
variable from the configuration file.
Returns:
str or None: The value of the variable if found, or None if not found.
"""
# Initialize variable
processing_stop_file = None
# Open the file and read its contents
with open(CONFIG_FILE_PATH, "r") as f:
for line in f:
# Split the line into variable name and value
variable_name, value = line.strip().split("=")
# Check if the variable we are looking for exists in the line
if variable_name == "COMMBASE_HARDWARE_COMMAND_PROCESSING_STOP_FILE":
# Remove the quotes from the value of the variable
processing_stop_file = CONFIG_FILE_DIR + value.strip()[1:-1]
# Check if the variable was found
if processing_stop_file is not None:
return processing_stop_file
# If the variable was not found, return None
return None
def get_commbase_hardware_device_0():
"""
Retrieves the value of the COMMBASE_HARDWARE_DEVICE_0 variable from the
configuration file.
Returns:
str or None: The value of the variable if found, or None if not found.
"""
# Initialize variable
hardware_device_0 = None
# Open the file and read its contents
with open(CONFIG_FILE_PATH, "r") as f:
for line in f:
# Split the line into variable name and value
variable_name, value = line.strip().split("=")
# Check if the variable we are looking for exists in the line
if variable_name == "COMMBASE_HARDWARE_DEVICE_0":
# Remove the quotes from the value of the variable
hardware_device_0 = value.strip()[1:-1]
# Check if the variable was found
if hardware_device_0 is not None:
return hardware_device_0
# If the variable was not found, return None
return None
def get_commbase_stt_whisper_reactive_p_client_data_file():
"""
Retrieves the value of the COMMBASE_STT_WHISPER_REACTIVE_P_CLIENT_DATA_FILE
variable from the configuration file.
Returns:
str or None: The value of the variable if found, or None if not found.
"""
# Initialize variable
recording_file = None
# Open the file and read its contents
with open(CONFIG_FILE_PATH, "r") as f:
for line in f:
# Split the line into variable name and value
variable_name, value = line.strip().split("=")
# Check if the variable we are looking for exists in the line
if variable_name == "COMMBASE_STT_WHISPER_REACTIVE_P_CLIENT_DATA_FILE":
# Remove the quotes from the value of the variable
recording_file = CONFIG_FILE_DIR + value.strip()[1:-1]
# Check if the variable was found
if recording_file is not None:
return recording_file
# If the variable was not found, return None
return None