Skip to content

Commit

Permalink
Merge pull request #86 from AI4WA/doc
Browse files Browse the repository at this point in the history
Doc
  • Loading branch information
PascalSun authored Jul 26, 2024
2 parents 2263b0e + 8b10df9 commit 902db50
Show file tree
Hide file tree
Showing 29 changed files with 1,088 additions and 487 deletions.
4 changes: 3 additions & 1 deletion API/api/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,9 @@
STORAGE_SOLUTION_LOCAL = "local"
STORAGE_SOLUTION_S3 = "s3"
STORAGE_SOLUTION_VOLUME = "volume"
STORAGE_SOLUTION = os.environ.get("STORAGE_SOLUTION", "s3")
STORAGE_SOLUTION = os.environ.get("STORAGE_SOLUTION", STORAGE_SOLUTION_S3)
if STORAGE_SOLUTION == "":
STORAGE_SOLUTION = STORAGE_SOLUTION_API

# update this
S3_BUCKET = "openomni" # update this to your S3 bucket name
Expand Down
2 changes: 1 addition & 1 deletion Client/Listener/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def get_storage_solution(self):
return None
data = r.json()
logger.info(data)
return data.get("storage_solution", "volume")
return data.get("storage_solution", "local")

def upload_file(
self,
Expand Down
26 changes: 13 additions & 13 deletions Client/Listener/audios_acquire.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@

class AudioAcquire:
def __init__(
self,
api_domain: str = "",
token: str = "",
home_id: Optional[str] = "",
energy_threshold: int = 5000,
default_microphone: str = "pulse",
record_timeout: int = 30000,
sampling_time: float = 0.25,
track_cluster: Optional[str] = None,
self,
api_domain: str = "",
token: str = "",
home_id: Optional[str] = "",
energy_threshold: int = 5000,
default_microphone: str = "pulse",
record_timeout: int = 30000,
sampling_time: float = 0.25,
track_cluster: Optional[str] = None,
):
"""
The audio acquire class
Expand Down Expand Up @@ -131,9 +131,9 @@ def record_callback(_, audio: sr.AudioData) -> None:
curr_audio_dir.mkdir(parents=True, exist_ok=True)

with open(
curr_audio_dir
/ f"{self.audio_index}-{sample_time.strftime('%Y%m%d%H%M%S')}.wav",
"wb",
curr_audio_dir
/ f"{self.audio_index}-{sample_time.strftime('%Y%m%d%H%M%S')}.wav",
"wb",
) as file:
file.write(wav_data)
self.audio_index += 1
Expand Down Expand Up @@ -209,7 +209,7 @@ def main():
"--default_microphone",
default="pulse",
help="Default microphone name for SpeechRecognition. "
"Run this with 'list' to view available Microphones.",
"Run this with 'list' to view available Microphones.",
type=str,
)
parser.add_argument(
Expand Down
16 changes: 9 additions & 7 deletions Client/Listener/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ def on_any_event(self, event):
"png",
]:
return None
return None
try:
self.s3_client.upload_file(
event.src_path,
Expand Down Expand Up @@ -150,12 +149,12 @@ def on_any_event(self, event):

class StorageHandler:
def __init__(
self,
api_domain: str = "",
token: str = "",
home_id: int = None,
dest_dir: Optional[str] = None,
dest_password: Optional[str] = None,
self,
api_domain: str = "",
token: str = "",
home_id: int = None,
dest_dir: Optional[str] = None,
dest_password: Optional[str] = None,
):
"""
Args:
Expand Down Expand Up @@ -199,6 +198,9 @@ def process_s3(self):

def process_local_network(self):
observer = Observer()
if not self.dest_dir:
logger.error("dest_dir is required for local network sync")
return
local_handler = LocalSyncHandler(
src_path=str(DATA_DIR),
dest_path=self.dest_dir,
Expand Down
Loading

0 comments on commit 902db50

Please sign in to comment.