Giter Club home page Giter Club logo

Comments (8)

charleschen84 avatar charleschen84 commented on June 13, 2024
  1. call setUp()
  2. send audio data to the shared data buffer in a loop
  3. waketrigger wil call startRecognizing when a hotword detected. AVS will send stopCapture Directive to AIP and send play response audio to Speecher/MediaPlayer.

Here are some of my code:

`m_detector = kwd::KittAiKeyWordDetector::create(
m_AudioBuffer,
m_compatibleAudioFormat,
{m_WakeWordTrigger},
std::unordered_set<std::shared_ptr>(),
inputPath + RESOURCE_FILE,
{config},
2.0,
false);
assert(nullptr != m_detector);

  m_mediaPlayer = MediaPlayer::create();
  assert(nullptr != m_mediaPlayer);

  // Create and register the SpeechSynthesizer.
  m_speechSynthesizer = SpeechSynthesizer::create(m_mediaPlayer,
                                                  m_avsConnectionManager,
                                                  m_focusManager,
                                                  m_contextManager,
                                                  m_attachmentManager,
                                                  m_exceptionEncounteredSender);

  m_speechSynthesizerObserver = std::make_shared<TestSpeechSynthesizerObserver>();
  m_speechSynthesizer->addObserver(m_speechSynthesizerObserver);`

`void AlexaClient::StartService(void)
{
PortAudioWrapper pa_wrapper(COMPATIBLE_SAMPLE_RATE,
COMPATIBLE_NUM_CHANNELS,
COMPATIBLE_SAMPLE_SIZE_IN_BITS);

  std::vector<int16_t> audioData;
  while(1) {
      pa_wrapper.Read(&audioData);
      if(!audioData.empty()) {
          m_AudioBufferWriter->write(audioData.data(), audioData.size());
      }
  }

}`

from avs-device-sdk.

kencecka avatar kencecka commented on June 13, 2024

Hi Boyce,

There shouldn't be any problem with running multiple cycles, and your lifecycle flow sounds correct. Are you having specific problems implementing the cycle test?

Ken

from avs-device-sdk.

boyce-xx avatar boyce-xx commented on June 13, 2024

Hi @kencecka

From what we have tried based on the flow above, we need to disconnect/connect AVS again to keep the inquiry process normal, but it costs 3s~4s to reconnect with AVS, we expect to inquire AVS more than once without disconnecting and connecting with AVS again and again.

The flow what we expected is: initial -> connect -> startRecognizing -> stopCapture -> play response audio --> startRecognizing -> stopCapture -> play response audio --> startRecognizing -> .........

But if we skip the disconnect/connect step, we can inquire AVS for 2 times normally, then we got the following errors when trying a 3rd time:

SharedDataStream::createReader failed: all readers are already in use.
InProcessAttachmentReader:ConstructorFailed:reason=could not create an SDS reader
InProcessAttachmentReader:createFailed:reason=object not fully created
executeRecognize failed: Failed to create attachment reader.
/home/king/Project/DB20_Linux/AVS/alexa-client-sdk_v0.4.1_desktop/alexa-client-sdk/Integration/test/AlexaAudioLongRunTest.cpp:692: Failure
Value of: m_tapToTalkButton->startRecognizing(m_AudioInputProcessor, m_TapToTalkAudioProvider)
Actual: false
Expected: true
MessageRouter:connectionStatusChanged:reason=ACL_CLIENT_REQUEST,newStatus=DISCONNECTED
DirectiveSequencer:shutdown
executeOnFocusChanged: Lost focus.

[ FAILED ] AlexaAudioTest.avsFunctionTest (19913 ms)
[----------] 1 test from AlexaAudioTest (19913 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (19913 ms total)
[ PASSED ] 0 tests.
[ FAILED ] 1 test, listed below:
[ FAILED ] AlexaAudioTest.avsFunctionTest

1 FAILED TEST

For a better user experience, we want to have a seamless inquiry between cycles.
Thanks.

from avs-device-sdk.

kencecka avatar kencecka commented on June 13, 2024

Hi Boyce,

You are correct in your expectation that you should not need to disconnect and reconnect. Looking at your log above, it appears that you are encountering a similar issue to the one described here. We are investigating, and will update you when we have more details. In the mean time, if you are able to provide some sample code that reproduces the issue, that may help with debugging, as we are not currently seeing this issue with our own testing.

Thanks,
Ken

from avs-device-sdk.

boyce-xx avatar boyce-xx commented on June 13, 2024

Hi @kencecka

Please see this

Thanks.

from avs-device-sdk.

boyce-xx avatar boyce-xx commented on June 13, 2024

Hi @kencecka ,
I have tried again based on V0.5 SDK, but get the same error, error message is:

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ testCycleIndex: 3
2017-06-24 08:54:30.589 [ 5] I ?:?::SharedDataStream::createReader failed: all readers are already in use.
2017-06-24 08:54:30.589 [ 5] E InProcessAttachmentReader:ConstructorFailed:reason=could not create an SDS reader
2017-06-24 08:54:30.589 [ 5] E InProcessAttachmentReader:createFailed:reason=object not fully created
2017-06-24 08:54:30.589 [ 5] E AudioInputProcessor:executeRecognizeFailed:reason=Failed to create attachment reader
/home/king/Project/DB20_Linux/AVS/alexa-client-sdk_v0.5_desktop/alexa-client-sdk/Integration/test/AlexaAudioLongRun2Test.cpp:625: Failure
Value of: m_tapToTalkButton->startRecognizing(m_AudioInputProcessor, m_TapToTalkAudioProvider)
Actual: false
Expected: true
2017-06-24 08:54:30.590 [ 1] 0 MessageRouter:connectionStatusChanged:reason=ACL_CLIENT_REQUEST,newStatus=DISCONNECTED
2017-06-24 08:54:30.664 [ 1] I DirectiveSequencer:shutdown
2017-06-24 08:54:30.664 [ 8] I DirectiveRouter:cancelDirective:messageId=178cc7c1-32ba-4a38-aaa2-2196a5f4fce3,action=calling
[ FAILED ] AlexaAudioTest.avsFunctionTest (30302 ms)
[----------] 1 test from AlexaAudioTest (30302 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (30302 ms total)
[ PASSED ] 0 tests.
[ FAILED ] 1 test, listed below:
[ FAILED ] AlexaAudioTest.avsFunctionTest

1 FAILED TEST

sample code like this

from avs-device-sdk.

kencecka avatar kencecka commented on June 13, 2024

Hi Boyce,

I think I see where you are running in to trouble. Your sample code is a modified version of AudioInputProcessorIntegartionTest.cpp. That test tries to thoroughly verify that all aspects of the SDK interacting with AVS are working as expected. One piece of this is to verify that the correct events are being sent out to AVS.

To do this, the integration test inserts a shim (TestMessageSender) between AudioInputProcessor and AVSConnectionManager. That shim maintains a queue of MessageRequests internally, and only discards them if you call waitForNext() on the shim. The test uses this to verify every MessageRequest that passes from AudioInputProcessor to AVSConnectionManager. However, if you are using the shim and you neglect to call waitForNext(), it will simply accumulate all the MessageRequests in its queue and never discard them.

Reviewing your code, I see:

        // Check that a recognize event was sent.
        //ASSERT_TRUE(checkSentEventName(m_avsConnectionManager, NAME_RECOGNIZE));

If I uncomment the ASSERT_TRUE, I no longer see the createReader() error, and am able to run hundreds of iterations.

Note that there is no need for a shim like this in a normal use case. You can connect your AudioInputProcessor directly to your AVSConnectionManager, and this issue will go away.

Hope that helps,
Ken

from avs-device-sdk.

boyce-xx avatar boyce-xx commented on June 13, 2024

Hi @kencecka ,
Thanks for your great support, It works now.

-- I removed the shim(TestMessageSender), and add a object of acl::AVSConnectionManager, It works for me.

from avs-device-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.