Fixed bug

This commit is contained in:
2024-09-15 01:50:45 -04:00
parent 2fbca72f63
commit f369e09a0c

View File

@@ -63,6 +63,8 @@ def record_transmissions(device_id: int):
frames = [] # Reset frames to start fresh for this transmission
elif recording and not nonsilent_chunks:
# Check if there were valid nonsilent chunks before trimming
if len(nonsilent_chunks) > 0:
# Transmission has ended (silence detected for the required duration)
if len(frames) > 0:
# Save recording without leading/trailing silence
@@ -74,6 +76,9 @@ def record_transmissions(device_id: int):
frames.clear() # Clear frames to prepare for the next transmission
print("Recording stopped, waiting for the next transmission...")
# Optionally: adjust silence threshold if needed
# E.g., try increasing silence_thresh to detect lower sounds
def parse_arguments():
parser = argparse.ArgumentParser()
@@ -84,8 +89,8 @@ def parse_arguments():
if __name__ == "__main__":
try:
args = parse_arguments()
logger.info("Arguments: %s", args)
record_transmissions(device=args['device_id'])
print("Arguments: %s", args)
record_transmissions(args.device_id)
except KeyboardInterrupt:
print("Stopping...")
finally: