Australia
Asked

How To Detect If Sound Is Played Though The PC Sound Board And Run A Script

How can I detect if sound is being played through the PC's sound card and then execute a script in Synthiam ARC? The Sound servo Skill doesn't seem to provide an option to trigger a script.

I'm looking for a way to monitor audio output and initiate a script based on sound activity. Any guidance on how to achieve this within the ARC environment would be appreciated.


Related Hardware EZ-B v4
Related Control Speech Script

ARC Pro

Upgrade to ARC Pro

Subscribe to ARC Pro, and your robot will become a canvas for your imagination, limited only by your creativity.

PRO
Canada
#1  

To detect if sound is being played through the PC's sound card and execute a script in Synthiam ARC, you can use the Speech Script skill to monitor when speech is being played. However, if you want to monitor general audio output from the PC's sound card, you might need to use a workaround since ARC doesn't directly support monitoring all PC audio output.

Here's a step-by-step guide to achieve this using the Speech Script skill:

  1. Add the Speech Script Skill:

    • Ensure you have the Speech Script skill added to your ARC project. This skill can execute scripts when speech starts and ends.
  2. Configure the Speech Script:

    • Open the configuration window of the Speech Script skill.
    • You will see two script sections: "Script Start Speaking" and "Script End Speaking."
  3. Script Start Speaking:

    • This script will execute when any robot skill or script begins speaking within ARC.
    • You can add your custom script here to perform actions when speech starts. For example, you can move servos, turn on LEDs, etc.
  4. Script End Speaking:

    • This script will execute when the speech is completed.
    • You can use this script to restore your robot to a default state or perform any cleanup actions.
  5. Example Script:

    • Here's an example script that moves a servo on port D0 as a jaw when speech is detected:
    var words = getVar($SpeechTxt).split(" ");
    for (var wi = 0; wi < words.length; wi++) {
        for (var i = 0; i < words[wi].length; i++) {
            var c = words[wi][i];
            switch (c) {
                case 'a':
                case 'e':
                case 'i':
                case 'o':
                case 'u':
                case 'y':
                    // Open mouth for vowels
                    Servo.setPosition(d0, 100);
                    sleep(100);
                    break;
                case '.':
                case ',':
                case '?':
                case '!':
                    // Close mouth for end of sentence
                    Servo.setPosition(d0, 10);
                    sleep(500);
                    break;
                default:
                    // Close mouth for consonants
                    Servo.setPosition(d0, 10);
                    sleep(100);
                    break;
            }
        }
    }
    
  6. Testing:

    • Test the setup by triggering speech in ARC and observing the servo movements or any other actions you have scripted.

If you need to monitor general audio output from the PC's sound card, you might need to explore external solutions or software that can detect audio output and trigger actions in ARC through a different method, such as sending commands via a network or serial interface.

Feel free to ask if you have more questions or need further assistance!


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
PRO
Australia
#2  

@Athena Alas I need a script to monitor audio output from the PC's sound card that is not generated within ARC.

PRO
Canada
#3  

Monitoring audio output from the PC's sound card that is not generated within ARC directly through ARC is not natively supported. However, you can achieve this by using external software or scripts that can detect audio output and then communicate with ARC to trigger actions. Here's a general approach you can take:

Step-by-Step Guide

  1. External Audio Monitoring Software:

    • Use an external software or script that can monitor the audio output of your PC. There are several third-party applications and libraries that can detect when audio is playing on your system. For example, you can use Python libraries like pyaudio or sounddevice to monitor audio levels.
  2. Script to Monitor Audio:

    • Write a script in Python (or another language) that uses the audio monitoring library to detect when sound is playing. Here's a basic example using Python and sounddevice:

      import sounddevice as sd
      import numpy as np
      
      def audio_callback(indata, frames, time, status):
          volume_norm = np.linalg.norm(indata) * 10
          if volume_norm > 0.1:  # Adjust the threshold as needed
              print("Sound detected!")
      
      stream = sd.InputStream(callback=audio_callback)
      with stream:
          sd.sleep(10000)  # Monitor for 10 seconds
      
  3. Communicate with ARC:

    • Once your script detects audio, you need a way to communicate with ARC to trigger a script. You can do this using ARC's HTTP server feature or by sending commands via a serial or network interface.
    • For example, you can use ARC's HTTP server to send a command to ARC when audio is detected. You would need to set up ARC to listen for HTTP requests and execute a script when a request is received.
  4. Set Up ARC to Receive Commands:

    • In ARC, you can use the HTTP server feature to listen for incoming requests. Configure ARC to execute a specific script when it receives a request from your audio monitoring script.
  5. Testing and Adjustments:

    • Test the entire setup to ensure that when audio is detected by your external script, ARC receives the command and executes the desired actions.
    • Adjust the audio detection threshold and timing as needed to suit your specific requirements.

Additional Resources

This approach requires some programming and setup outside of ARC, but it allows you to monitor audio output from the PC's sound card and trigger actions in ARC based on that detection. If you have any questions or need further assistance, feel free to ask!


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
PRO
Australia
#4  

@Athena Thanks for the information albeit a complex solution. All that's really needed is a new Sound Script Skill based on the Sound servo Skill which does know when sound is being played through the PC's sound card.

PRO
Canada
#5  

Creating a new Sound Script Skill based on the Sound servo Skill to detect when sound is being played through the PC's sound card and execute a script is a great idea. While this feature isn't natively available in ARC, you can suggest it as a feature request to Synthiam. They might consider adding it in future updates if there's enough interest.

In the meantime, here's a conceptual approach to how such a skill could work:

Conceptual Approach for a Sound Script Skill

  1. Sound Detection:

    • The skill would monitor the audio output levels from the PC's sound card, similar to how the Sound servo Skill detects audio levels to move servos.
  2. Script Execution:

    • When the audio level exceeds a certain threshold, indicating that sound is being played, the skill would trigger a user-defined script.
    • The script could perform any action, such as moving servos, turning on LEDs, or any other behavior supported by ARC.
  3. Configuration Options:

    • Users could configure the audio threshold level that triggers the script.
    • Users could specify the script to execute when sound is detected.
  4. Integration with ARC:

    • The skill would integrate seamlessly with ARC, allowing users to add it to their projects and configure it through the ARC interface.

Suggesting the Feature

To suggest this feature to Synthiam, you can:

  • Visit the Synthiam website and navigate to the community forums or support section.
  • Post a feature request detailing your idea for a Sound Script Skill, explaining how it would work and the benefits it would provide.
  • Engage with other users to gather support for the feature request, increasing the likelihood of it being considered.

If you have any more questions or need further assistance, feel free to ask!


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.