Open WhistleMaster opened 2 years ago
It's on my list to investigate. I'm rewriting deconz integration right now. Then I'll solve some bugs with unifi then I hope to get back to the Axis integration
Great news ! I would be happy to test and provide information if needed.
Don't expect it to happen before summer though :/
I have too much to do which is the main issue
Summer is the best time to test ;-) No worries !
I'm doing some tests in the meanwhile and I can send sample sounds to the internal speaker with the following command:
ffmpeg -i <sound_file.mp3> -probesize 32 -analyzeduration 32 -c:a pcm_mulaw -ab 128k -ac 1 -ar 16000 -f wav -chunked_post 0 -content_type audio/axis-mulaw-128 "http://<user>:<password>@<cam_ip>/axis-cgi/audio/transmit.cgi"
Oo wow! Awesome job.
Thanks ! Just some good old google-fu to be honest 😇 nothing more. I would like to help to implement that in your add-on but not sure if that really helps... It's a start but I guess that's something that should use some POST to send the sound file to the transmit.cgi and see it as a media_player entity.
If you can just give me a proof of concept in python code I can formalize it afterwards
I've tried to do something like that, as a PoC, which works fine:
import requests
from requests.auth import HTTPDigestAuth
from pydub import AudioSegment
from pydub.utils import mediainfo
# Set Auth
auth = HTTPDigestAuth("<USER>", "<PASSWORD>")
# Set the server URL
server_url = "http://<IP>/axis-cgi/audio/transmit.cgi"
# Open the MP3 file
input_file = AudioSegment.from_mp3("sound.mp3")
# Convert the MP3 file to WAV format
input_file = input_file.split_to_mono()[0]
input_file = input_file.set_frame_rate(16000)
input_file = input_file.export(
"output.wav", format="wav", codec="pcm_mulaw", bitrate="128k")
# Print some info about the WAV
print(mediainfo("output.wav"))
# Read the WAV file and get its data
with open("output.wav", "rb") as f:
file_data = f.read()
# Set the headers for the HTTP POST request
headers = {
"Content-Type": "audio/axis-mulaw-128",
"Content-Length": str(len(file_data)),
}
try:
# Send the POST request with the file data and headers
response = requests.post(server_url, data=file_data,
auth=auth, headers=headers)
print(response.text)
response.raise_for_status()
except requests.exceptions.HTTPError as errh:
print("Http Error:", errh)
except requests.exceptions.ConnectionError as errc:
print("Error Connecting:", errc)
except requests.exceptions.Timeout as errt:
print("Timeout Error:", errt)
except requests.exceptions.RequestException as err:
print("OOps: Something Else", err)
I've also found some documentation here: https://www.axis.com/vapix-library/subjects/t10100065/section/t10036015/display
Sweet! I've taken my first small steps into the refactoring of the Axis library so once I'm further into that I can start looking at adding new things as it would be counterproductive to expand something that will be rewritten shortly after.
FYI, I posted a PR for speaker support in HA here: https://github.com/home-assistant/core/pull/130163
Awesome 🎉
Hi,
Thanks for the great work !
I've recently installed a new AXIS I8016-LVE and I was wondering if the internal speaker could be seen in HA as a media_player entity. The Synology surveillance client can send any sound file to the speaker, so there may be a way I guess. Then, that could also be applied to other AXIS Network Speakers such as the C1410.
What information would you need that could help ?
Thanks ! Kind regards,
WM