Announcement

Collapse
No announcement yet.

Speak message from Channel Roger?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Speak message from Channel Roger?

    There is a channel in IFTTT called Roger which works with the DropBox channel - Once I speak to Roger, a dropbox TXT file is created with the following contents:

    Created at: September 9, 2016 at 08:23PM
    Conversation: Roger
    Speaker: Wayne
    Audio URL: http://ift.tt/2c0ewqq
    Public listen URL: http://ift.tt/2bYIo1m

    The Speaker is the phone that was used (mine), the Audio and public listen URL are populated by the app.

    Is there any way to have this plugin speak the Audio URL to a homeseer speaker? I am trying to make a whole house intercom where I can speak to Roger and have my homeseer speaker client (which is the page input to my whole house audio system) - then, I can page the whole house by simply using roger....

    Ideas are greatly appreciated!

  • #2
    this one almost works, but how to play a m4a file on Homeseer clients?

    Hi rileydogmi,

    I suppose you're using spuds IFTTT plugin, so you might be able to use the $ifft_ globalvar feature to parse the audiourl and use in a script see last part in manual:
    http://board.homeseer.com/showthread.php?t=166058

    Then you need a script to download the file to your homeseer system.
    I've included some code you can use in an event.

    The last part is to play the downloaded audio file on your system. But this step in the script does not work because the audio format of the audiofile is m4a and HomeSeer cannot handle this type of file for speaker clients. I tried play it with hs.speak (see code) but this part does not work.

    Maybe someone else has suggestions how to play this kind of audio files (m4a).

    Cheers,
    Zigmund
    Code:
    Imports System.Text.RegularExpressions
    
    Sub Main(parm as Object)
         Dim audiourl As String = hs.GetVar("ifttt_audiourl")
       Try
         If audiourl.Length > 0  Then
              Dim urlregexPattern As String = "^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?"
              Dim m As Match = Regex.Match(audiourl, urlregexPattern)
              If m.Success Then 
                      Dim URLHost As String = m.Groups(4).Value 'strip hostname from url
                      Dim URLPath As String = m.Groups(5).Value 'strip webpage from url
                      hs.WriteLog("SpeakURL", "downloading: " & URLHost & URLPath)
                      hs.GetURLex(URLhost, URLPath, "", 80, False, False, "/tmp/speak.m4a")
                      hs.Speak("/tmp/speak.m4a", True)
             Else
                      hs.WriteLog("SpeakURL", "Something went wrong") 
             End If
          End if
       Catch Ex As Exception
            hs.WriteLog("SpeakURL", "Error: " & ex.Message)
       End Try
    End Sub

    Comment


    • #3
      This is a great start - thanks!

      I believe HS can speak WAV - there is an online service I found called Zamzar (may be others) that offer 100 free conversions per month via an API - they have example code in many formats (C#, Shell, PHP) in their docs but I am unsure how to add it to the script. Their Shell example is below:

      Code:
       curl https://sandbox.zamzar.com/v1/jobs \
       -u 0f33876a0fa29a25ddd1be26f3aeff7efe319e7b: \
       -X POST \
       -F "source_file=@/tmp/portrait.gif" \
       -F "target_format=png"
      The -u above is the API key they generated for me (the above one isn't mine, it is their example) - it is free to get a key. The source can be the mp4 file, the target format will support WAV.

      The JSON response they show is

      Code:
      {
          "id" : 15,
          "key" : "0f33876a0fa29a25ddd1be26f3aeff7efe319e7b",
          "status" : "initialising",
          "sandbox" : true,
          "created_at" : "2013-10-27T13:41:00Z",
          "finished_at" : null,
          "source_file" : {"id":2,"name":"portrait.gif","size":90571},
          "target_files" : [],
          "target_format" : "png",
          "credit_cost" : 1
      }
      I don't think I need to consume the response because it is a confirmation...

      Can I just use a hs.GetURLex to replace the curl command? Not sure how to pass the parameters though.

      Thanks!!!

      Comment


      • #4
        ffmpeg

        or install ffmpeg from ffmpeg.org you can convert it locally to mp3

        Launch /usr/bin/ffmpeg With Parameters: -y -i /tmp/speak.m4a -acodec libmp3lame /tmp/speak.mp3

        and then hs.speak("/tmp/speak.mp3", True)

        Comment


        • #5
          It works!!!!

          I have this event implemented now and it works GREAT!!! So now, I launch my iOS app Roger, press a single button, speak and within 10 seconds or so my speech plays over the whole house page. A cheap intercom system - what is neat with Roger is I can create users for each room - so, I can have a popup of speak to kitchen, etc -- I haven't done that yet but sure it is possible. With Roger you are limited to 100 per month for free but for me, that is more than enough. Thanks Zigmund for your help!

          I am attaching the screenshot of the script below. A few notes for those who want to do this.

          1) The full command parameters for ffmpeg are cutoff on the screen shot - they are:
          Code:
          -y -i "C:\Program Files (x86)\Homeseer HS3\Temp\speak.m4a" -acodec libmp3lame -ab 256k "C:\Program Files (x86)\HomeSeer HS3\Temp\speak.mp3"
          2) I had to make sure each command waited to execute until the next step - VERY important

          3) I add the "Announce" speak command line as a trigger to wake my page input - if I omit this, I loose a small portion of the announcement so this wakes-up the WH audio to play the whole file

          4) The vb script I got to work is as follows:

          Code:
          Imports System.Text.RegularExpressions
          
          Sub Main (ByVal parm as object)
             Dim audiourl as String = hs.GetVar("ifttt_audiourl")
             hs.WriteLog("SpeakURL", audiourl)
          
             Try
               If audiourl.Length > 0  Then
                    Dim urlregexPattern As String = "^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?"
                    Dim m As Match = Regex.Match(audiourl, urlregexPattern)
                    If m.Success Then 
                            Dim URLHost As String = m.Groups(4).Value 'strip hostname from url
                            Dim URLPath As String = m.Groups(5).Value 'strip webpage from url
                            hs.WriteLog("SpeakURL", "downloading: " & URLHost & URLPath)
                            hs.GetURLex(URLhost, URLPath, "", 80, False, False, "/temp/speak.m4a")
                   Else
                            hs.WriteLog("SpeakURL", "Something went wrong") 
                   End If
                End if
             Catch Ex As Exception
                  hs.WriteLog("SpeakURL", "Error: " & ex.Message)
            End Try
          
          End Sub
          Hope someone else can use this and make it better - might be nice to put all this on one vb script but for some reason I got errors. Thanks for all your help.
          Attached Files

          Comment


          • #6
            well done

            Well done. Glad I could help you.

            Comment

            Working...
            X