diff --git a/asl3_wx_announce/audio.py b/asl3_wx_announce/audio.py index 8f8e06b..8aa4dcd 100644 --- a/asl3_wx_announce/audio.py +++ b/asl3_wx_announce/audio.py @@ -31,12 +31,26 @@ class AudioHandler: raise e def play_on_nodes(self, filepath: str, nodes: List[str]): - # Asterisk uses file path WITHOUT extension usually for play commands. - # KD5FMU script uses absolute path successfully (e.g. /tmp/current-time) + # Asterisk usually wants paths relative to the sounds directory if they are inside it. + # e.g. "rpt localplay asl3_wx_announce/report" + path_no_ext = os.path.splitext(filepath)[0] + # Standard sounds root + sounds_root = "/var/lib/asterisk/sounds/" + + if path_no_ext.startswith(sounds_root): + # Strip root: /var/lib/asterisk/sounds/dir/file -> dir/file + play_path = path_no_ext[len(sounds_root):] + # Ensure no leading slash + if play_path.startswith("/"): + play_path = play_path[1:] + else: + # Outside standard dir, use absolute + play_path = path_no_ext + for node in nodes: - asterisk_cmd = f'asterisk -rx "rpt localplay {node} {path_no_ext}"' + asterisk_cmd = f'asterisk -rx "rpt localplay {node} {play_path}"' self.logger.info(f"Playing on {node}: {asterisk_cmd}") try: subprocess.run(asterisk_cmd, shell=True, check=True) diff --git a/asl3_wx_announce/provider/similar git hub projects.txt b/asl3_wx_announce/provider/similar git hub projects.txt new file mode 100644 index 0000000..da5e50b --- /dev/null +++ b/asl3_wx_announce/provider/similar git hub projects.txt @@ -0,0 +1,5 @@ +https://github.com/KD5FMU/Play-Audio-Locally +https://github.com/KD5FMU/Time-Weather-Announce +https://github.com/KD5FMU/Play-Audio-ASL3-Node +https://github.com/KD5FMU/Convert-Audio-File-to-ulaw +https://github.com/KD5FMU/Saytime-Weather-FIX-for-HamVoip diff --git a/package.tar b/package.tar new file mode 100644 index 0000000..4446a4c Binary files /dev/null and b/package.tar differ