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

port/tests_from_core #168

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open

port/tests_from_core #168

wants to merge 2 commits into from

Conversation

JarbasAl
Copy link
Member

@JarbasAl JarbasAl commented Oct 15, 2024

Summary by CodeRabbit

  • New Features

    • Added new configuration files for the Mycroft system in Brazilian Portuguese and various formats (JSON, YAML).
    • Introduced unit tests for configuration management to enhance reliability.
  • Bug Fixes

    • Removed outdated or unnecessary TTS configuration entries from multiple language files to streamline settings.
  • Documentation

    • Added copyright notice and licensing information to the configuration test file.

Copy link
Contributor

coderabbitai bot commented Oct 15, 2024

Walkthrough

The changes in this pull request involve modifications to several configuration files related to TTS (text-to-speech) settings across different languages, including the removal of specific configurations. Additionally, new configuration files for the Mycroft system in Brazilian Portuguese and other formats (JSON, YAML) have been introduced. A copyright notice was added to a test file, and a suite of unit tests for configuration management was created.

Changes

File Path Change Summary
ovos_config/recommends/offline_male/fr-fr.conf Removed two empty lines at the beginning; no other changes.
ovos_config/recommends/offline_male/it-it.conf Removed the "voice" setting under "ovos-tts-plugin-piper".
ovos_config/recommends/offline_male/nl-nl.conf Removed the entire TTS configuration block for "ovos-tts-plugin-piper".
test/unittests/configuration/init.py Added copyright notice and licensing information at the beginning.
test/unittests/configuration/mycroft.conf Introduced new configuration file for Mycroft in Brazilian Portuguese with TTS settings.
test/unittests/configuration/mycroft.json Introduced new JSON configuration file for voice assistant settings.
test/unittests/configuration/mycroft.yml Introduced new YAML configuration file for Mycroft AI system settings.
test/unittests/configuration/test_configuration.py Added unit tests for configuration management, including multiple test methods for various scenarios.

Possibly related PRs

  • feat:autoconfigure language #158: The changes in this PR involve configuration settings related to language and TTS options, which are directly relevant to the modifications made in the main PR regarding TTS configurations in various language-specific files.

Poem

In the land of code where rabbits play,
Configs were changed in a tidy way.
TTS settings gone, new files in sight,
Mycroft's voice sings, oh what a delight!
With tests in place, our work is done,
Hopping along, we’ve had our fun! 🐇✨


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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.

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: 5

🧹 Outside diff range and nitpick comments (14)
test/unittests/configuration/test_configuration.py (3)

1-10: Address the TODO comment about moving the test class.

The TODO comment suggests moving this test class to ovos-config. This would improve the organization and maintainability of the test suite.

Would you like assistance in creating a GitHub issue to track the task of moving this test class to ovos-config?


32-62: LGTM! Comprehensive test for LocalConf with a minor suggestion.

The test_local method thoroughly tests the LocalConf class, covering:

  1. Initialization with mocked file operations and JSON loading.
  2. Merging of configurations.
  3. Storing configurations.
  4. Edge cases like non-existent files and directories.

This approach ensures robust testing of the LocalConf class under various scenarios.

Consider adding a test case for merging nested dictionaries to ensure deep merging works correctly. This would further improve the test coverage.


64-81: LGTM! Thorough test for file format compatibility with a suggestion.

The test_file_formats method effectively tests the compatibility between YAML and JSON configurations by:

  1. Loading configurations from both formats and comparing them.
  2. Exporting configurations to both formats and verifying the results.
  3. Ensuring that the exported configurations match the original ones.

This approach guarantees that configurations can be seamlessly used across different file formats.

Consider adding assertions to verify the content of the exported files, not just their existence. This could involve reading the exported files and comparing their content with the original configurations.

test/unittests/configuration/mycroft.yml (10)

1-12: Consider resource implications of multiple active audio backends.

The configuration enables multiple audio backends (OCP, simple, and VLC) simultaneously. While this provides flexibility, it might impact system resources. Consider evaluating the necessity of having all backends active by default and potentially disabling unused ones to optimize resource usage.


13-30: Reconsider cache path and debug settings.

  1. The cache path is set to a temporary directory (/tmp/mycroft/cache). This may lead to data loss upon system reboot. Consider using a more persistent location for the cache.

  2. Debug mode is set to false, which is suitable for production. However, for testing and troubleshooting purposes, you might want to create a separate configuration or implement a mechanism to easily toggle debug mode.


30-48: Ensure consistency in wake word engines and review thresholds.

  1. The configuration uses different wake word engines for "hey mycroft" (Precise) and "wake up" (Pocketsphinx). Consider using the same engine for both to ensure consistent behavior and easier maintenance.

  2. The threshold for "wake up" (1.0e-20) seems very low compared to "hey mycroft" (1.0e-90). This might lead to frequent false positives. Consider adjusting this threshold to a more appropriate value to balance sensitivity and accuracy.


53-81: Validate VAD settings and review recording timeout.

  1. The VAD settings are comprehensive, but they might need fine-tuning based on real-world performance. Consider implementing a mechanism to easily adjust these settings during testing phases.

  2. The recording_timeout is set to 10 seconds, which might be too long for some use cases and could lead to unnecessary processing of silence. Consider reducing this timeout or implementing a dynamic timeout based on detected speech activity.


82-99: Make location and timezone configurable.

The current configuration hardcodes the location to Lawrence, Kansas, USA, and the timezone to Central Standard Time. For a more flexible and user-friendly system, consider:

  1. Implementing a mechanism to automatically detect the user's location and timezone.
  2. Allowing users to manually set their location and timezone through a settings interface.
  3. Using a location service API to fetch accurate location data based on IP address or user input.

This approach would make the system more adaptable to different user locations and preferences.


100-105: Enhance network configuration flexibility.

  1. The current configuration uses Google's public DNS servers. While these are reliable, they might not be suitable for all deployment scenarios. Consider making the DNS server addresses configurable or using the system's default DNS settings.

  2. The NCSI (Network Connectivity Status Indicator) endpoint is set to a Microsoft URL. This might not be reliable for all network configurations. Consider:

    • Making the NCSI endpoint configurable.
    • Implementing multiple connectivity check methods (e.g., ping, HTTP GET) to various reliable endpoints.
    • Allowing users to define their own connectivity check endpoints.

These changes would make the system more adaptable to different network environments and user preferences.


130-153: Enhance skill management and security.

  1. The blacklisted_skills array is empty. Consider implementing a mechanism to easily blacklist skills that might pose security risks or cause performance issues. This could include:

    • A predefined list of known problematic skills.
    • A user-configurable blacklist.
    • An automated system to detect and blacklist misbehaving skills.
  2. The priority skills (mycroft-pairing and mycroft-volume) seem appropriate for core system functionality. However, consider:

    • Implementing a validation mechanism to ensure these skills are always available and functional.
    • Allowing for dynamic priority assignment based on user behavior or system state.
    • Documenting the criteria for designating a skill as high priority.

These enhancements would improve system security, performance, and user experience.


159-163: Enhance STT reliability and offline capabilities.

  1. The primary STT module is set to "ovos-stt-plugin-server", which relies on an external server. Consider:

    • Implementing a mechanism to seamlessly switch between online and offline STT based on network availability.
    • Caching frequently used speech-to-text conversions for improved offline performance.
  2. While having a fallback STT module (ovos-stt-plugin-vosk) is good practice, consider:

    • Implementing error handling and logging for STT failures.
    • Adding configuration options for users to customize the STT pipeline based on their needs (e.g., accuracy vs. speed, online vs. offline preference).

These enhancements would improve the system's reliability and flexibility in various network conditions.


184-187: Optimize TTS settings and enhance customization.

  1. The pulse_duck setting is set to false. Consider enabling this feature to improve audio clarity during TTS playback by temporarily lowering the volume of other audio sources.

  2. To enhance user experience, consider implementing:

    • Voice selection options for both primary and fallback TTS engines.
    • Speed and pitch adjustment settings for TTS output.
    • A mechanism to easily switch between online (higher quality) and offline (lower latency) TTS based on network availability or user preference.

These enhancements would provide users with more control over the voice interface and improve overall system flexibility.


188-193: Enhance websocket security configuration.

  1. The websocket is currently configured to listen on all interfaces (0.0.0.0). While this provides flexibility, it may pose security risks in certain environments. Consider:

    • Allowing configuration of specific interfaces or IP ranges for websocket connections.
    • Implementing IP whitelisting for added security in controlled environments.
  2. SSL is currently disabled. To protect against potential data interception, especially in untrusted networks, consider:

    • Enabling SSL by default and providing clear documentation on how to configure SSL certificates.
    • Implementing a secure key exchange mechanism for initial connection setup.
  3. While shared connection is enabled, which can be efficient, ensure that proper authentication and authorization mechanisms are in place to prevent unauthorized access to shared resources.

These enhancements would significantly improve the security posture of the websocket communication.

test/unittests/configuration/mycroft.json (1)

19-33: Consider using a more persistent cache location.

The current cache path (/tmp/mycroft/cache) is in a temporary directory, which might not persist across system reboots. Consider using a more persistent location, such as /var/cache/mycroft or a user-specific directory like ~/.cache/mycroft.

Other general settings look appropriate for a default configuration.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 86bf0f8 and 4ea687f.

📒 Files selected for processing (8)
  • ovos_config/recommends/offline_male/fr-fr.conf (0 hunks)
  • ovos_config/recommends/offline_male/it-it.conf (0 hunks)
  • ovos_config/recommends/offline_male/nl-nl.conf (0 hunks)
  • test/unittests/configuration/init.py (1 hunks)
  • test/unittests/configuration/mycroft.conf (1 hunks)
  • test/unittests/configuration/mycroft.json (1 hunks)
  • test/unittests/configuration/mycroft.yml (1 hunks)
  • test/unittests/configuration/test_configuration.py (1 hunks)
💤 Files with no reviewable changes (3)
  • ovos_config/recommends/offline_male/fr-fr.conf
  • ovos_config/recommends/offline_male/it-it.conf
  • ovos_config/recommends/offline_male/nl-nl.conf
✅ Files skipped from review due to trivial changes (1)
  • test/unittests/configuration/init.py
🧰 Additional context used
🔇 Additional comments (10)
test/unittests/configuration/mycroft.conf (4)

1-9: LGTM: Well-structured configuration file

The overall structure of the configuration file is well-organized and follows proper JSON formatting. The use of nested objects for related settings (e.g., "tts" and its sub-settings) is appropriate and enhances readability.


2-2: Correct language code for Brazilian Portuguese

The language setting "pt-br" is the correct ISO 639-1 code for Brazilian Portuguese. This aligns with the PR objective of configuring Mycroft for Brazilian Portuguese.


1-9: Consider additional configuration settings for comprehensive testing

While this configuration file provides basic language and TTS settings, which may be sufficient for specific unit tests, consider whether additional configuration settings are needed for more comprehensive testing. Typical Mycroft configurations often include:

  1. Speech-to-Text (STT) settings
  2. Skill configurations
  3. System-specific settings

Adding these elements, if relevant to the tests, could provide a more realistic test environment and potentially uncover edge cases or integration issues.

To check if other test configuration files include these additional settings, you can run:

#!/bin/bash
# Search for other test configuration files and their contents
fd -e conf -e json -e yaml . test | xargs -I {} sh -c 'echo "File: {}"; cat {} | jq -C . 2>/dev/null || cat {}; echo "\n"'

This will help determine if the minimal configuration in this file is intentional or if it should be expanded to match other test configurations.


3-8: Verify optimal eSpeak voice for Brazilian Portuguese

The TTS configuration using eSpeak is appropriate, as it supports multiple languages including Portuguese. The "f1" voice setting likely refers to a female voice, which is a common convention in eSpeak.

However, it's worth verifying if "f1" is the optimal voice for Brazilian Portuguese in eSpeak. There might be more specific or higher-quality voices available for this language.

To verify the available voices for Brazilian Portuguese in eSpeak, you can run the following command:

This will list all available Portuguese voices. Check if there's a more suitable voice specifically for Brazilian Portuguese (pt-br).

test/unittests/configuration/test_configuration.py (3)

13-31: LGTM! Well-structured test for RemoteConf.

The test_remote method effectively tests the RemoteConf class by:

  1. Mocking external dependencies (RemoteConfigManager and is_paired).
  2. Setting up a mock API with predefined configuration data.
  3. Verifying that methods are called as expected (download and is_paired).
  4. Checking that configuration values are correctly retrieved.

This comprehensive approach ensures that the RemoteConf class behaves correctly under controlled conditions.


83-90: LGTM! Robust test for YAML configuration loading.

The test_yaml_config_load method effectively verifies the correct loading of YAML configurations by:

  1. Ensuring that loaded data structures are dictionaries and not OrderedDicts.
  2. Checking both the main configuration and nested structures.
  3. Verifying that the configuration can be serialized to JSON and deserialized back without loss of information.

This comprehensive approach ensures that YAML configurations are handled correctly and maintain their structure throughout processing.


1-90: Overall, excellent test suite for configuration management.

This test file provides comprehensive coverage for the LocalConf and RemoteConf classes, including:

  1. Remote configuration handling and pairing.
  2. Local configuration loading, merging, and storing.
  3. File format compatibility between YAML and JSON.
  4. Correct loading and structure preservation of YAML configurations.

The use of mocking is appropriate and effective in isolating the system under test. The suggestions provided are minor and aim to further enhance an already robust test suite.

Great job on creating a thorough and well-structured set of tests!

test/unittests/configuration/mycroft.json (3)

2-18: Audio configuration looks good.

The audio configuration provides a flexible setup with multiple backends (OCP, simple, and vlc) and sets OCP as the default. This approach allows for fallback options and adaptability to different audio requirements.


1-234: Overall assessment of the configuration file.

This configuration file provides a comprehensive setup for a voice assistant system. It covers crucial aspects such as audio handling, wake word detection, STT, TTS, skills management, and system settings. However, there are several areas that could be improved:

  1. Security: Consider the suggestions for the websocket configuration and wake word upload settings.
  2. Flexibility: Make certain hardcoded values (like STT server URL) more configurable.
  3. Performance: Review wake word detection thresholds and expand TTS configuration options.
  4. Privacy: Implement user consent mechanisms for data collection features.
  5. Persistence: Use a more permanent location for the cache directory.

While the current configuration is functional, implementing these suggestions would result in a more robust, secure, and user-friendly system.

To ensure the configuration is valid JSON, you can run:


40-58: Review wake word detection thresholds.

The wake word detection thresholds for both "hey mycroft" (1e-90) and "wake up" (1e-20) seem extremely low. Such low thresholds might lead to frequent false positive activations. Consider adjusting these values based on real-world testing to find a balance between sensitivity and accuracy.

The use of multiple wake words and different engines (Precise for "hey mycroft" and PocketSphinx for "wake up") provides good flexibility for users.

To help verify the impact of these thresholds, you could run the following script:

test/unittests/configuration/mycroft.json Show resolved Hide resolved
test/unittests/configuration/mycroft.json Show resolved Hide resolved
test/unittests/configuration/mycroft.json Show resolved Hide resolved
test/unittests/configuration/mycroft.json Show resolved Hide resolved
test/unittests/configuration/mycroft.json Show resolved Hide resolved
@JarbasAl
Copy link
Member Author

not sure why tests passed in core but not in this repo, any ideas @NeonDaniel ?

@NeonDaniel
Copy link
Member

not sure why tests passed in core but not in this repo, any ideas @NeonDaniel ?

Maybe a difference in configuration patching? Or just the FileWatcher not triggering an update? I've had inconsistent results with changes to config files triggering a reload..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants