Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:stream extraction #97

Merged
merged 9 commits into from
Sep 12, 2024
Merged

fix:stream extraction #97

merged 9 commits into from
Sep 12, 2024

Conversation

JarbasAl
Copy link
Member

@JarbasAl JarbasAl commented Sep 12, 2024

use the stream extractors before delegating to audio service

allows directly sending things such as youtube urls to the audio service bus api

closes #81

Summary by CodeRabbit

  • New Features

    • Enhanced audio playback functionality with improved handling of audio tracks.
    • Introduced support for new Text-to-Speech and media playback plugins.
    • Added a test case for processing YouTube URLs, improving the validation of audio service behavior.
  • Bug Fixes

    • Improved robustness of the audio playback method to better handle audio streams.
    • Added tests to ensure the extraction process functions correctly for various media URLs.

use the stream extractors before delegating to audio service
Copy link
Contributor

coderabbitai bot commented Sep 12, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request introduces enhancements to the audio playback functionality in the ovos_audio/audio.py file, including a new private method for extracting audio streams from track URIs. Additionally, the requirements/extras.txt file has been updated to include new dependencies for TTS and media playback, improving the overall capabilities of the project. The GitHub Actions workflow for unit tests has also been modified to ensure that additional dependencies are included during testing.

Changes

File Change Summary
ovos_audio/audio.py Added a private method _extract for converting track URIs into playable streams; modified play method.
requirements/extras.txt Added dependencies: ovos-tts-plugin-server, ovos_audio_plugin_simple, and ovos-audio-plugin-mpv.
.github/workflows/unit_tests.yml Changed installation command to include extra dependencies during unit tests.
test/unittests/test_end2end.py Added a new test case test_youtube for validating YouTube URL handling in audio service.
test/unittests/test_service.py Introduced TestStreamExtract class to test _extract method functionality.

Assessment against linked issues

Objective Addressed Explanation
OCP extractors failing when OCP is set to legacy audio service (#81) The introduction of the _extract method addresses the extraction failure for audio streams.

Possibly related PRs

  • fix:stream extraction #97: The changes in this PR directly relate to the introduction of the _extract method in ovos_audio/audio.py, which is also a key feature of the main PR. Both PRs enhance audio playback functionality by ensuring that track URIs are converted into playable streams.

Poem

🐇 In the land of audio streams,
A rabbit hops and gleams,
With plugins new and bright,
Playback dances in delight,
Extracting tunes with flair,
Hopping high without a care! 🎶


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added fix and removed fix labels Sep 12, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4ac71b1 and ecadb86.

Files selected for processing (2)
  • ovos_audio/audio.py (2 hunks)
  • requirements/extras.txt (1 hunks)
Additional context used
LanguageTool
requirements/extras.txt

[locale-violation] ~2-~2: 'server' é un xenismo. É preferíbel dicir "servidor"
Context: # TTS Plugins ovos-tts-plugin-server>=0.0.2, <1.0.0 # Media Playback plugin...

(GL_BARBARISM_REPLACE)


[untranslated] ~4-~4: A palabra «Playback» é un anglicismo. Empregue mellor "son pregravado" ou "son de estudio".
Context: ...s-plugin-server>=0.0.2, <1.0.0 # Media Playback plugins ovos_audio_plugin_simple>=0.1.0...

(PLAYBACK)

Ruff
ovos_audio/audio.py

388-388: Undefined name List

(F821)


388-388: Undefined name Union

(F821)


388-388: Undefined name Tuple

(F821)


388-388: Undefined name List

(F821)


391-391: Undefined name load_stream_extractors

(F821)

Additional comments not posted (5)
requirements/extras.txt (3)

1-2: LGTM!

The new dependency for the TTS plugin server with the specified version constraint is approved.

Tools
LanguageTool

[locale-violation] ~2-~2: 'server' é un xenismo. É preferíbel dicir "servidor"
Context: # TTS Plugins ovos-tts-plugin-server>=0.0.2, <1.0.0 # Media Playback plugin...

(GL_BARBARISM_REPLACE)


5-5: LGTM!

The new dependency for basic audio playback capabilities with the specified version constraint is approved.


6-7: LGTM!

The new dependency for integration with the MPV media player with the specified version constraint is approved.

ovos_audio/audio.py (2)

388-397: LGTM!

The new _extract method is a useful addition to handle the extraction of playable streams from various types of track URIs. The code is well-structured, follows a clear logic, and correctly handles both string URIs and tuples containing URIs and MIME types. The use of a lazy-loaded singleton of stream extractors is a good design choice for efficiency.

Tools
Ruff

388-388: Undefined name List

(F821)


388-388: Undefined name Union

(F821)


388-388: Undefined name Tuple

(F821)


388-388: Undefined name List

(F821)


391-391: Undefined name load_stream_extractors

(F821)


419-419: LGTM!

The modification to the play method is a necessary addition to integrate the new _extract method. It ensures that the play method only operates on valid, extractable audio streams, enhancing the functionality and robustness of the method.

ovos_audio/audio.py Outdated Show resolved Hide resolved
use the stream extractors before delegating to audio service
use the stream extractors before delegating to audio service
@github-actions github-actions bot added fix and removed fix labels Sep 12, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Outside diff range and nitpick comments (2)
test/unittests/test_service.py (1)

62-71: LGTM, but consider using a mock YouTube URL.

The code changes are approved. The test class and method are correctly implemented, and the test is skipped due to a valid reason.

However, consider using a mock YouTube URL or a URL from a test video that is less likely to change in the future. This will make the test more robust and less likely to break due to external factors.

test/unittests/test_end2end.py (1)

93-152: LGTM! Consider adding more assertions.

The new test case test_youtube is well-structured and effectively tests the handling of YouTube URLs by the audio service. It follows the AAA (Arrange-Act-Assert) pattern and is self-contained.

To further improve the test case, consider adding more assertions to validate the content of the emitted messages, such as checking the data field of the ovos.common_play.media.state and ovos.common_play.track.state messages to ensure that the correct media and track states are being set.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ecadb86 and eb9672b.

Files selected for processing (4)
  • .github/workflows/unit_tests.yml (1 hunks)
  • ovos_audio/audio.py (3 hunks)
  • test/unittests/test_end2end.py (1 hunks)
  • test/unittests/test_service.py (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • ovos_audio/audio.py
Additional comments not posted (1)
.github/workflows/unit_tests.yml (1)

53-53: LGTM!

The change to install the package with .[extras] is a good addition. It ensures that the optional dependencies are also installed during the testing phase, allowing the tests to cover the extended functionality provided by these dependencies.

@JarbasAl JarbasAl merged commit 9fc6ed7 into dev Sep 12, 2024
5 checks passed
@JarbasAl JarbasAl deleted the streams branch September 12, 2024 01:54
This was referenced Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OCP extractors failing when OCP is set to legacy audio service
1 participant