diff --git a/CHANGELOG.md b/CHANGELOG.md index 34d020a2c6..bc16dc4476 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,10 @@ Feature enhancements, updates, and resolved issues from all releases are availab **XMOS-only change** - version 0: + * refactor CLI arguments in setup scripts in order to support Amazon KWD * port XMOS KWD adapters to latest version of the SDK * delay startup of AVS console till .asoundrc file is found + * clone portaudio from github instead of using wget as it is more reliable ### Version 1.25.0 - August 23 2021 Feature enhancements, updates, and resolved issues from all releases are available on the [Amazon developer portal](https://developer.amazon.com/docs/alexa/avs-device-sdk/release-notes.html) diff --git a/applications/acsdkSensoryAdapter/acsdkKWD/src/KWDComponent.cpp b/applications/acsdkSensoryAdapter/acsdkKWD/src/KWDComponent.cpp index b907912553..e9bdeecd1a 100644 --- a/applications/acsdkSensoryAdapter/acsdkKWD/src/KWDComponent.cpp +++ b/applications/acsdkSensoryAdapter/acsdkKWD/src/KWDComponent.cpp @@ -46,12 +46,15 @@ static std::shared_ptr createA std::shared_ptr keywordNotifier, std::shared_ptr keywordDetectorStateNotifier) { std::string modelFilePath; +#ifdef SENSORY_OP_POINT + uint32_t operatingPoint = 0; +#endif // SENSORY_OP_POINT + auto config = avsCommon::utils::configuration::ConfigurationNode::getRoot()[SAMPLE_APP_CONFIG_ROOT_KEY] [SENSORY_CONFIG_ROOT_KEY]; if (config) { config.getString(SENSORY_MODEL_FILE_PATH, &modelFilePath); #ifdef SENSORY_OP_POINT - uint32_t operatingPoint = 0; config.getUint32(SENSORY_SNSR_OPERATING_POINT, &operatingPoint); SensoryKeywordDetector::setSnsrOperatingPoint(operatingPoint); #endif // SENSORY_OP_POINT @@ -61,7 +64,7 @@ static std::shared_ptr createA return nullptr; } #ifdef SENSORY_OP_POINT - if (m_snsrOperatingPoint==0) { + if (operatingPoint==0) { ACSDK_ERROR(LX("createFailed").d("reason", "zeroSnsrOperatingPoint")); return nullptr; } diff --git a/applications/acsdkSensoryAdapter/include/acsdkSensoryAdapter/Sensory/SensoryKeywordDetector.h b/applications/acsdkSensoryAdapter/include/acsdkSensoryAdapter/Sensory/SensoryKeywordDetector.h index ece68c202a..2e00ea1e67 100644 --- a/applications/acsdkSensoryAdapter/include/acsdkSensoryAdapter/Sensory/SensoryKeywordDetector.h +++ b/applications/acsdkSensoryAdapter/include/acsdkSensoryAdapter/Sensory/SensoryKeywordDetector.h @@ -96,6 +96,7 @@ class SensoryKeywordDetector : public acsdkKWDImplementations::AbstractKeywordDe */ ~SensoryKeywordDetector() override; +#ifdef SENSORY_OP_POINT /** * Set the operating point of the SNSR engine. * @@ -105,6 +106,7 @@ class SensoryKeywordDetector : public acsdkKWDImplementations::AbstractKeywordDe static void setSnsrOperatingPoint(int value) { m_snsrOperatingPoint = value; }; +#endif // SENSORY_OP_POINT private: /** diff --git a/applications/acsdkSensoryAdapter/src/SensoryKeywordDetector.cpp b/applications/acsdkSensoryAdapter/src/SensoryKeywordDetector.cpp index 74d481ed01..dee322d18f 100644 --- a/applications/acsdkSensoryAdapter/src/SensoryKeywordDetector.cpp +++ b/applications/acsdkSensoryAdapter/src/SensoryKeywordDetector.cpp @@ -58,6 +58,10 @@ static const avsCommon::utils::AudioFormat::Encoding SENSORY_COMPATIBLE_ENCODING static const avsCommon::utils::AudioFormat::Endianness SENSORY_COMPATIBLE_ENDIANNESS = avsCommon::utils::AudioFormat::Endianness::LITTLE; +#ifdef SENSORY_OP_POINT +uint32_t SensoryKeywordDetector::m_snsrOperatingPoint = 0; +#endif // SENSORY_OP_POINT + /** * Checks to see if an @c avsCommon::utils::AudioFormat is compatible with Sensory. * @@ -353,7 +357,7 @@ bool SensoryKeywordDetector::setUpRuntimeSettings(SnsrSession* session) { return false; } ACSDK_INFO(LX("setUpRuntimeSettings") - .d("operating point",op)); + .d("operating point", op)); #endif // SENSORY_OP_POINT return true; } diff --git a/applications/acsdkXMOSAdapter/XMOS/include/XMOS/XMOSKeywordDetector.h b/applications/acsdkXMOSAdapter/XMOS/include/XMOS/XMOSKeywordDetector.h index b6cecb35ba..029a4c4934 100644 --- a/applications/acsdkXMOSAdapter/XMOS/include/XMOS/XMOSKeywordDetector.h +++ b/applications/acsdkXMOSAdapter/XMOS/include/XMOS/XMOSKeywordDetector.h @@ -52,44 +52,6 @@ class XMOSKeywordDetector : public acsdkKWDImplementations::AbstractKeywordDetec public: - /** - * Creates an @c XMOSKeywordDetector - * - * @param stream The stream of audio data. This should be formatted in LPCM encoded with 16 bits per sample and - * have a sample rate of 16 kHz. Additionally, the data should be in little endian format. - * @param audioFormat The format of the audio data located within the stream. - * @param keyWordNotifier The object with which to notifiy observers of keyword detections. - * @param KeyWordDetectorStateNotifier The object with which to notify observers of state changes in the engine. - * @param msToPushPerIteration The amount of data in milliseconds to push to the cloud at a time. This was the amount used by - * Sensory in example code. - */ - static std::unique_ptr create( - const std::shared_ptr stream, - const std::shared_ptr& audioFormat, - std::shared_ptr keyWordNotifier, - std::shared_ptr KeyWordDetectorStateNotifier, - std::chrono::milliseconds msToPushPerIteration = std::chrono::milliseconds(10)); - - /** - * @deprecated - * Creates an @c XMOSKeywordDetector - * - * @param stream The stream of audio data. This should be formatted in LPCM encoded with 16 bits per sample and - * have a sample rate of 16 kHz. Additionally, the data should be in little endian format. - * @param audioFormat The format of the audio data located within the stream. - * @param keyWordObservers The observers to notify of keyword detections. - * @param keyWordDetectorStateObservers The observers to notify of state changes in the engine. - * @param msToPushPerIteration The amount of data in milliseconds to push to the cloud at a time. This was the amount used by - * Sensory in example code. - * @return A new @c XMOSKeywordDetector, or @c nullptr if the operation failed. - */ - static std::unique_ptr create( - const std::shared_ptr stream, - avsCommon::utils::AudioFormat audioFormat, - std::unordered_set> keyWordObservers, - std::unordered_set> keyWordDetectorStateObservers, - std::chrono::milliseconds msToPushPerIteration = std::chrono::milliseconds(10)); - /** * Destructor. */ diff --git a/tools/Install/pi.sh b/tools/Install/pi.sh index 78c2d69e79..c5e509a712 100644 --- a/tools/Install/pi.sh +++ b/tools/Install/pi.sh @@ -24,35 +24,6 @@ if [ -z "$PLATFORM" ]; then exit 1 fi -show_help() { - echo 'Usage: pi.sh [OPTIONS]' - echo '' - echo 'Optional parameters' - echo ' -G Flag to enable keyword detector on GPIO interrupt' - echo ' -H Flag to enable keyword detector on HID event' - echo ' -S Flag to enable Sensory keyword detector' - echo ' -h Display this help and exit' -} -OPTIONS=GHSh -while getopts "$OPTIONS" opt ; do - case $opt in - G ) - GPIO_KEY_WORD_DETECTOR_FLAG="ON" - ;; - H ) - HID_KEY_WORD_DETECTOR_FLAG="ON" - ;; - S ) - SENSORY_KEY_WORD_DETECTOR_FLAG="ON" - ;; - - h ) - show_help - exit 1 - ;; - esac -done - SOUND_CONFIG="$HOME/.asoundrc" START_SCRIPT="$INSTALL_BASE/startsample.sh" START_PREVIEW_SCRIPT="$INSTALL_BASE/startpreview.sh" @@ -64,18 +35,26 @@ CMAKE_PLATFORM_SPECIFIC=(-DGSTREAMER_MEDIA_PLAYER=ON \ -DCURL_LIBRARY=${THIRD_PARTY_PATH}/curl-${CURL_VER}/lib/.libs/libcurl.so) # Add the flags for the different keyword detectors -if [ -n "$SENSORY_KEY_WORD_DETECTOR_FLAG" ] -then - CMAKE_PLATFORM_SPECIFIC+=(-DSENSORY_KEY_WORD_DETECTOR=ON \ +case $KEY_WORD_DETECTOR_FLAG in + S ) + # Set CMAKE options for Sensory Keyword detector + CMAKE_PLATFORM_SPECIFIC+=(-DSENSORY_KEY_WORD_DETECTOR=ON \ + -DSENSORY_OP_POINT=ON \ + -DXMOS_AVS_TESTS=ON \ -DSENSORY_KEY_WORD_DETECTOR_LIB_PATH=$THIRD_PARTY_PATH/alexa-rpi/lib/libsnsr.a \ -DSENSORY_KEY_WORD_DETECTOR_INCLUDE_DIR=$THIRD_PARTY_PATH/alexa-rpi/include) -elif [ -n "$GPIO_KEY_WORD_DETECTOR_FLAG" ] -then - CMAKE_PLATFORM_SPECIFIC+=(-DGPIO_KEY_WORD_DETECTOR=ON) -elif [ -n "$HID_KEY_WORD_DETECTOR_FLAG" ] -then - CMAKE_PLATFORM_SPECIFIC+=(-DHID_KEY_WORD_DETECTOR=ON) -fi + ;; + A ) + # Set CMAKE options for Amazon Keyword detector + CMAKE_PLATFORM_SPECIFIC+="" + ;; + G ) + CMAKE_PLATFORM_SPECIFIC+=(-DGPIO_KEY_WORD_DETECTOR=ON) + ;; + H ) + CMAKE_PLATFORM_SPECIFIC+=(-DHID_KEY_WORD_DETECTOR=ON) + ;; +esac GSTREAMER_AUDIO_SINK="alsasink" @@ -87,7 +66,7 @@ install_dependencies() { run_os_specifics() { build_port_audio build_curl - if [ [ -z $GPIO_KEY_WORD_DETECTOR_FLAG ] && [ -z $HID_KEY_WORD_DETECTOR_FLAG ] && [ -z $SENSORY_KEY_WORD_DETECTOR_FLAG ] ] + if [ [ -z $KEY_WORD_DETECTOR_FLAG ] ] then echo echo "==============> TAP-TO-TALK IS ENABLED ==============" diff --git a/tools/Install/setup.sh b/tools/Install/setup.sh index b45f080f61..e9fca5b098 100755 --- a/tools/Install/setup.sh +++ b/tools/Install/setup.sh @@ -25,8 +25,13 @@ set -o nounset # Exit the script if any uninitialized variable is used. CLONE_URL=${CLONE_URL:- 'https://github.com/xmos/avs-device-sdk.git'} -PORT_AUDIO_FILE="pa_stable_v190600_20161030.tgz" -PORT_AUDIO_DOWNLOAD_URL="http://www.portaudio.com/archives/$PORT_AUDIO_FILE" +# Download portaudio from github as it is more reliable than the website +# Comment out old variables +# PORT_AUDIO_FILE="pa_stable_v190600_20161030.tgz" +# PORT_AUDIO_DOWNLOAD_URL="https://github.com/PortAudio/portaudio/releases/tag/pa_stable_v190600_20161030" +PORT_AUDIO_TAG="pa_stable_v190600_20161030" +PORT_AUDIO_CLONE_URL="https://github.com/PortAudio/portaudio" +PORT_AUDIO_DIR="portaudio" CURL_VER=7.67.0 CURL_DOWNLOAD_URL="https://github.com/curl/curl/releases/download/curl-7_67_0/curl-${CURL_VER}.tar.gz" @@ -62,9 +67,6 @@ PATH_FILES_DIR="$HOME/.config/" VOCALFUSION_3510_SALES_DEMO_PATH_FILE="$PATH_FILES_DIR/vocalfusion_3510_sales_demo_path" VOCALFUSION_3510_AVS_SETUP_PATH_FILE="$PATH_FILES_DIR/vocalfusion_3510_avs_setup_path" PI_HAT_CTRL_PATH="$THIRD_PARTY_PATH/pi_hat_ctrl" -SENSORY_KEY_WORD_DETECTOR_FLAG="" -GPIO_KEY_WORD_DETECTOR_FLAG="" -HID_KEY_WORD_DETECTOR_FLAG="" ALIASES="$HOME/.bash_aliases" # Default value for XMOS device @@ -93,10 +95,13 @@ build_port_audio() { echo "==============> BUILDING PORT AUDIO ==============" echo pushd $THIRD_PARTY_PATH - wget -c $PORT_AUDIO_DOWNLOAD_URL - tar zxf $PORT_AUDIO_FILE + # Download portaudio from github as it is more reliable than the website + # Comment out old lines + # wget -c $PORT_AUDIO_DOWNLOAD_URL + # tar zxf $PORT_AUDIO_FILE - pushd portaudio + git clone -b $PORT_AUDIO_TAG $PORT_AUDIO_CLONE_URL + pushd $PORT_AUDIO_DIR ./configure --without-jack make popd @@ -137,9 +142,7 @@ show_help() { echo ' -i PKCS#11 user pin to access key object functions.' echo ' -k PKCS#11 key object label.' echo ' -x XMOS device to setup: possible values are xvf3100, xvf3500, xvf3510, xvf3600-slave, xvf3600-master, or xvf3610, default is xvf3510' - echo ' -G Flag to enable keyword detector on GPIO interrupt' - echo ' -H Flag to enable keyword detector on HID interrupt' - echo ' -S Flag to enable Sensory keyword detector' + echo ' -w Keyword detector to setup: possible values are S (Sensory), A (Amazon), G (GPIO trigger), H (HID trigger), default is no keyword detector, only tap-to-talk is enabled' echo ' -h Display this help and exit' } @@ -159,7 +162,9 @@ XMOS_TAG=$2 shift 2 -OPTIONS=s:a:d:hp:k:i:t:m:x:GHSh +KEY_WORD_DETECTOR_FLAG="" + +OPTIONS=s:a:d:hp:k:i:t:m:x:w:h while getopts "$OPTIONS" opt ; do case $opt in s ) @@ -182,14 +187,8 @@ while getopts "$OPTIONS" opt ; do x ) XMOS_DEVICE="$OPTARG" ;; - G ) - GPIO_KEY_WORD_DETECTOR_FLAG="-G" - ;; - H ) - HID_KEY_WORD_DETECTOR_FLAG="-H" - ;; - S ) - SENSORY_KEY_WORD_DETECTOR_FLAG="-S" + w ) + KEY_WORD_DETECTOR_FLAG="$OPTARG" ;; h ) show_help @@ -263,8 +262,8 @@ PLATFORM=${PLATFORM:-$(get_platform)} if [ "$PLATFORM" == "Raspberry pi" ] then - PI_CMD="pi.sh ${SENSORY_KEY_WORD_DETECTOR_FLAG} ${GPIO_KEY_WORD_DETECTOR_FLAG} ${HID_KEY_WORD_DETECTOR_FLAG}" - echo "Running command ${PI_CMD}" + PI_CMD="pi.sh" + echo "Running command \"${PI_CMD}\" with KEY_WORD_DETECTOR_FLAG set to \"${KEY_WORD_DETECTOR_FLAG}\"" source $PI_CMD elif [ "$PLATFORM" == "Windows mingw64" ] then @@ -335,8 +334,7 @@ echo AUTOSTART_SESSION="avsrun" AUTOSTART_DIR=$HOME/.config/lxsession/LXDE-pi AUTOSTART=$AUTOSTART_DIR/autostart -AVSRUN_CMD="lxterminal -t avsrun -e \"$BUILD_PATH/SampleApp/src/SampleApp $OUTPUT_CONFIG_FILE " -AVSRUN_CMD+="NONE\" &" +AVSRUN_CMD="lxterminal -t avsrun -e \"$BUILD_PATH/SampleApp/src/SampleApp $OUTPUT_CONFIG_FILE NONE\" & " STARTUP_SCRIPT=$CURRENT_DIR/.avsrun-startup.sh if [ ! -f $AUTOSTART ]; then @@ -399,15 +397,6 @@ while true; do esac done -if [ -n "$SENSORY_KEY_WORD_DETECTOR_FLAG" ] -then - SENSORY_OP_POINT_FLAG="-DSENSORY_OP_POINT=ON" - XMOS_AVS_TESTS_FLAG="-DXMOS_AVS_TESTS=ON" -else - SENSORY_OP_POINT_FLAG="-DSENSORY_OP_POINT=OFF" - XMOS_AVS_TESTS_FLAG="-DXMOS_AVS_TESTS=OFF" -fi - if [ $XMOS_DEVICE = "xvf3510" ] then PI_HAT_FLAG="-DPI_HAT_CTRL=ON" @@ -465,9 +454,7 @@ then mkdir -p $BUILD_PATH cd $BUILD_PATH cmake "$SOURCE_PATH/avs-device-sdk" \ - $SENSORY_OP_POINT_FLAG \ $PI_HAT_FLAG \ - $XMOS_AVS_TESTS_FLAG \ -DCMAKE_BUILD_TYPE=DEBUG \ -DPKCS11=$ACSDK_PKCS11 \ "${CMAKE_PLATFORM_SPECIFIC[@]}"