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

Add autoconfig support to installer #170

Merged
merged 11 commits into from
Oct 11, 2024
Merged

Conversation

suvanbanerjee
Copy link
Contributor

@suvanbanerjee suvanbanerjee commented Oct 9, 2024

Closes #157

Summary by CodeRabbit

  • New Features

    • Introduced automatic configuration for Speech-to-Text (STT) and Text-to-Speech (TTS) based on user language settings.
    • Enhanced configuration for STT and TTS auto-configuration when the installation profile is not set to "server".
    • Added performance improvements in task execution for managing virtual environments.
  • Bug Fixes

    • Improved readability and performance in existing tasks without altering functionality.

@suvanbanerjee
Copy link
Contributor Author

@goldyfruit will this file structure work, I will ask user for autoconfig questions and then run the command accordingly, to tackle the region issue we can find region using their ip to detect their country so if someone chooses English in Australia then its en-au,
en-> from his language choice
au-> from his country ip

@JarbasAl
Copy link
Member

@goldyfruit will this file structure work, I will ask user for autoconfig questions and then run the command accordingly, to tackle the region issue we can find region using their ip to detect their country so if someone chooses English in Australia then its en-au, en-> from his language choice au-> from his country ip

i wouldnt worry about this for now, as the translations currently are all for en-us , setting a different code might just cause issues with no benefit

only portuguese currently differentiates between pt-br and pt-pt, no other language supports different dialect lang codes (yet)

@goldyfruit
Copy link
Member

I would not prompt any questions about the auto configuration. By default if French is selected then the assistant should be configured to in French, etc...

About the male or female voice, this question should be handle by the core team as its part of the OVOS's persona.

@JarbasAl @j1nx Do we want to have a male or female persona?

@goldyfruit goldyfruit added enhancement New feature or request translation Add or fix translation labels Oct 10, 2024
@goldyfruit goldyfruit added this to the Quake milestone Oct 10, 2024
@JarbasAl
Copy link
Member

team

If not prompting user, keep it male

@suvanbanerjee
Copy link
Contributor Author

If not prompting user, keep it male

I guess the standard for voice assistant is female ?

@JarbasAl
Copy link
Member

If not prompting user, keep it male

I guess the standard for voice assistant is female ?

historically we have used the male voice from alan pope, which goes well with "hey mycroft". let's keep it that way

besides, its a good differentiation factor in comparison with other voice assistants

@goldyfruit goldyfruit modified the milestones: Quake, Wolfenstein Oct 10, 2024
@goldyfruit goldyfruit modified the milestones: Wolfenstein, Descent Oct 10, 2024
@goldyfruit
Copy link
Member

goldyfruit commented Oct 10, 2024

@suvanbanerjee I just pushed a commit, please have a look.

@goldyfruit goldyfruit marked this pull request as ready for review October 10, 2024 21:53
Copy link
Contributor

coderabbitai bot commented Oct 10, 2024

Walkthrough

The pull request introduces new tasks in Ansible playbooks for auto-configuration of Speech-to-Text (STT) and Text-to-Speech (TTS) using the ovos-config command. This feature is conditionally executed based on the user's profile, specifically when it is not set to "server". Minor formatting adjustments were made to enhance the readability of existing tasks without altering their functionality.

Changes

File Path Change Summary
ansible/roles/ovos_installer/tasks/docker/composer.yml Added task for running ovos-config for STT and TTS auto-configuration; minor formatting adjustments made.
ansible/roles/ovos_installer/tasks/virtualenv/venv.yml Introduced task for running ovos-config for STT and TTS auto-configuration; updated file ownership command for performance.

Assessment against linked issues

Objective Addressed Explanation
Use ovos-config for STT and TTS auto-configuration (#[157])

🐇 In the garden where the code does play,
New tasks bloom bright, guiding the way.
With ovos-config, we sing and cheer,
Auto-configured voices, loud and clear!
TTS and STT, together they thrive,
In the world of speech, we come alive! 🌼


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

🧹 Outside diff range and nitpick comments (1)
ansible/roles/ovos_installer/tasks/docker/composer.yml (1)

Missing IP detection implementation and incomplete Jinja2 template updates

  1. IP Detection: The PR does not implement IP detection for region determination as outlined in the objectives.
  2. Jinja2 Template: The changes to mycroft.conf.j2 solely remove configurations without the expected updates, which contradicts the AI-generated summary.
🔗 Analysis chain

Line range hint 1-85: Clarify discrepancies between PR objectives, summary, and implemented changes

There are some inconsistencies between the PR objectives, the AI-generated summary, and the changes implemented in this file:

  1. The PR objectives mention using IP detection for region determination, but this is not implemented in the current file.
  2. The AI-generated summary mentions updates to the Jinja2 template for mycroft.conf.j2, which is not present in this file.

Could you please clarify if these features are implemented in other files not provided for review? If so, it would be helpful to see those changes as well to ensure a comprehensive review of the autoconfiguration feature.

To verify the implementation of these features, you can run the following script:

This script will search for any IP detection related code in the Ansible files and show the diff for the mycroft.conf.j2 template if it has been updated in this PR.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for IP detection and Jinja2 template updates

# Check for IP detection implementation
echo "Checking for IP detection implementation:"
rg --type yaml "ip.*detect" ansible/

# Check for updates to mycroft.conf.j2
echo "Checking for updates to mycroft.conf.j2:"
git diff HEAD~1 -- ansible/roles/ovos_installer/templates/mycroft.conf.j2

Length of output: 1373

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 5a7e631 and fc50a85.

📒 Files selected for processing (3)
  • ansible/roles/ovos_installer/tasks/docker/composer.yml (1 hunks)
  • ansible/roles/ovos_installer/tasks/virtualenv/venv.yml (1 hunks)
  • ansible/roles/ovos_installer/templates/mycroft.conf.j2 (0 hunks)
💤 Files with no reviewable changes (1)
  • ansible/roles/ovos_installer/templates/mycroft.conf.j2
🧰 Additional context used

Comment on lines 79 to 85
- name: Run ovos-config for auto-configuration of STT and TTS based on language
become: true
become_user: "{{ ovos_installer_user }}"
community.docker.docker_container_exec:
container: ovos_cli
command: ovos-config autoconfigure --lang {{ ovos_installer_locale }} --male

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance the auto-configuration task with conditional execution and error handling

The new task for auto-configuration of STT and TTS is a good addition that aligns with the PR objectives. However, consider the following improvements:

  1. Add conditional execution based on the ovos_installer_profile to ensure it only runs for the appropriate setup (e.g., satellite profile).
  2. Implement error handling and output capturing for better troubleshooting capabilities.
  3. Consider adding a variable for voice gender preference to allow flexibility, even if the default remains male.

Here's a suggested improvement:

- name: Run ovos-config for auto-configuration of STT and TTS based on language
  become: true
  become_user: "{{ ovos_installer_user }}"
  community.docker.docker_container_exec:
    container: ovos_cli
    command: ovos-config autoconfigure --lang {{ ovos_installer_locale }} {{ '--male' if ovos_installer_voice_gender|default('male') == 'male' else '--female' }}
  register: ovos_config_result
  when: ovos_installer_profile == "satellite"
  failed_when: ovos_config_result.rc != 0
  changed_when: ovos_config_result.rc == 0

- name: Debug ovos-config output
  ansible.builtin.debug:
    var: ovos_config_result
  when: ovos_installer_profile == "satellite"

This version adds conditional execution, error handling, and allows for voice gender preference while maintaining the male default.


🛠️ Refactor suggestion

Consider grouping related configuration tasks

The placement of the new auto-configuration task is logical in the current workflow. However, to improve the playbook's organization and readability, consider grouping related configuration tasks together.

You could create a block for all configuration-related tasks, including the Generate _identity.json task and this new auto-configuration task. This would make the playbook structure more clear and easier to maintain. For example:

- name: Configuration tasks
  block:
    - name: Generate _identity.json
      # ... existing task content ...

    - name: Run ovos-config for auto-configuration of STT and TTS based on language
      # ... new task content with suggested improvements ...

  when: ovos_installer_profile == "satellite"

This structure groups related tasks and applies the condition to both tasks, reducing redundancy and improving clarity.

Comment on lines 121 to 134
- name: Run ovos-config for auto-configuration of STT and TTS based on language
become: true
become_user: "{{ ovos_installer_user }}"
ansible.builtin.shell:
cmd: |
ovos-config autoconfigure \
--lang {{ ovos_installer_locale }} \
--male
executable: /bin/bash
environment:
PATH: "{{ ovos_installer_user_home }}/.venvs/ovos/bin"
VIRTUAL_ENV: "{{ ovos_installer_user_home }}/.venvs/ovos"
changed_when: false

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance the auto-configuration task for better flexibility and robustness.

The new task for auto-configuration of STT and TTS is a good addition, but there are a few areas for improvement:

  1. The --male option is hardcoded, which doesn't align with the discussion in the PR comments about allowing flexibility in voice persona selection. Consider making this configurable.

  2. The task lacks a conditional statement, meaning it will run for all installation profiles. This may not be necessary or desirable for all setups.

  3. There's no error handling or reporting for potential failures of the ovos-config command.

Consider applying the following improvements:

  1. Make the voice gender configurable:
ovos-config autoconfigure \
  --lang {{ ovos_installer_locale }} \
  {{ '--male' if ovos_installer_voice_gender == 'male' else '--female' }}
  1. Add a conditional statement to run only for relevant profiles:
when: ovos_installer_profile != 'server'
  1. Add error handling and reporting:
register: ovos_config_result
failed_when: ovos_config_result.rc != 0
  1. Consider adding a changed_when condition based on the output of the command to accurately reflect when changes occur.

These changes will make the task more flexible, efficient, and robust.

@goldyfruit
Copy link
Member

mycroft.conf generated by the ovos-config seems off.

{
  "log_level": "INFO",
  "play_wav_cmdline": "pw-play %1",
  "play_mp3_cmdline": "pw-play %1",
  "lang": "ca-ES",
  "listener": {
    "remove_silence": true,
    "VAD": {
      "module": "ovos-vad-plugin-silero"
    },
    "instant_listen": true
  },
  "skills": {
    "installer": {
      "allow_pip": true,
      "allow_alphas": true
    }
  },
  "websocket": {
    "max_msg_size": 25
  },
  "PHAL": {
    "ovos-PHAL-plugin-wifi-setup": {
      "module": "ovos-PHAL-plugin-wifi-setup",
      "lang": "ca-ES",
      "secondary_langs": [],
      "system_unit": "metric",
      "temperature_unit": "celsius",
      "windspeed_unit": "km/h",
      "precipitation_unit": "mm",
      "time_format": "full",
      "spoken_time_format": "half",
      "date_format": "DMY",
      "opt_in": false,
      "confirm_listening": true,
      "ready_settings": [
        "skills"
      ],
      "ignore_logs": [
        "enclosure.mouth.viseme",
        "enclosure.mouth.display"
      ],
      "enable_old_audioservice": true,
      "debug": false,
      "log_level": "INFO",
      "play_wav_cmdline": "pw-play %1",
      "play_mp3_cmdline": "pw-play %1",
      "first_boot": false
    }
  },
  "tts": {
    "ovos-tts-plugin-server": {
      "host": [
        "https://tts.smartgic.io/matxa",
        "https://matxa.ziggyai.online"
      ],
      "voice": "central/grau"
    },
    "module": "ovos-tts-plugin-server"
  },
  "stt": {
    "ovos-stt-plugin-server": {
      "url": [
        "https://stt.smartgic.io/citrinet",
        "https://citrinetstt.ziggyai.online"
      ]
    },
    "module": "ovos-stt-plugin-server",
    "fallback_module": ""
  },
  "system_unit": "metric",
  "temperature_unit": "celsius",
  "windspeed_unit": "km/h",
  "precipitation_unit": "mm",
  "time_format": "full",
  "spoken_time_format": "half",
  "date_format": "DMY"
}

@goldyfruit
Copy link
Member

mycroft.conf generated by the ovos-config seems off.

{
  "log_level": "INFO",
  "play_wav_cmdline": "pw-play %1",
  "play_mp3_cmdline": "pw-play %1",
  "lang": "ca-ES",
  "listener": {
    "remove_silence": true,
    "VAD": {
      "module": "ovos-vad-plugin-silero"
    },
    "instant_listen": true
  },
  "skills": {
    "installer": {
      "allow_pip": true,
      "allow_alphas": true
    }
  },
  "websocket": {
    "max_msg_size": 25
  },
  "PHAL": {
    "ovos-PHAL-plugin-wifi-setup": {
      "module": "ovos-PHAL-plugin-wifi-setup",
      "lang": "ca-ES",
      "secondary_langs": [],
      "system_unit": "metric",
      "temperature_unit": "celsius",
      "windspeed_unit": "km/h",
      "precipitation_unit": "mm",
      "time_format": "full",
      "spoken_time_format": "half",
      "date_format": "DMY",
      "opt_in": false,
      "confirm_listening": true,
      "ready_settings": [
        "skills"
      ],
      "ignore_logs": [
        "enclosure.mouth.viseme",
        "enclosure.mouth.display"
      ],
      "enable_old_audioservice": true,
      "debug": false,
      "log_level": "INFO",
      "play_wav_cmdline": "pw-play %1",
      "play_mp3_cmdline": "pw-play %1",
      "first_boot": false
    }
  },
  "tts": {
    "ovos-tts-plugin-server": {
      "host": [
        "https://tts.smartgic.io/matxa",
        "https://matxa.ziggyai.online"
      ],
      "voice": "central/grau"
    },
    "module": "ovos-tts-plugin-server"
  },
  "stt": {
    "ovos-stt-plugin-server": {
      "url": [
        "https://stt.smartgic.io/citrinet",
        "https://citrinetstt.ziggyai.online"
      ]
    },
    "module": "ovos-stt-plugin-server",
    "fallback_module": ""
  },
  "system_unit": "metric",
  "temperature_unit": "celsius",
  "windspeed_unit": "km/h",
  "precipitation_unit": "mm",
  "time_format": "full",
  "spoken_time_format": "half",
  "date_format": "DMY"
}

I removed the ovos-PHAL-plugin-wifi-setup package which is the culprit.

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 fc50a85 and d7886b7.

📒 Files selected for processing (2)
  • ansible/roles/ovos_installer/tasks/docker/composer.yml (1 hunks)
  • ansible/roles/ovos_installer/tasks/virtualenv/venv.yml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • ansible/roles/ovos_installer/tasks/docker/composer.yml
🧰 Additional context used

ansible/roles/ovos_installer/tasks/virtualenv/venv.yml Outdated Show resolved Hide resolved
@suvanbanerjee
Copy link
Contributor Author

thanks @goldyfruit for the pr's it made my job super easy 😅, i think this pr is ready to review and push, if there are any more changes please require do tell me

@goldyfruit
Copy link
Member

thanks @goldyfruit for the pr's it made my job super easy 😅

I mostly did it as you can learn from it for the next time.

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

🧹 Outside diff range and nitpick comments (1)
ansible/roles/ovos_installer/tasks/virtualenv/venv.yml (1)

121-135: Consider documenting the task order rationale

The placement of the new auto-configuration task after the _identity.json generation task seems appropriate. However, it's important to ensure that this order is intentional and necessary for the correct configuration of the system.

Consider adding a comment above the task to explain why this specific order is chosen. This will help future maintainers understand the reasoning behind the task placement and prevent potential issues if the order is changed inadvertently.

For example:

# Auto-configuration is performed after identity setup to ensure all necessary
# components are in place for language and voice configuration.
- name: Run ovos-config for auto-configuration of STT and TTS based on language
  # ... (rest of the task remains the same)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d7886b7 and 7e2c383.

📒 Files selected for processing (1)
  • ansible/roles/ovos_installer/tasks/virtualenv/venv.yml (1 hunks)
🧰 Additional context used

ansible/roles/ovos_installer/tasks/virtualenv/venv.yml Outdated Show resolved Hide resolved
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 7e2c383 and 9423a24.

📒 Files selected for processing (2)
  • ansible/roles/ovos_installer/tasks/docker/composer.yml (1 hunks)
  • ansible/roles/ovos_installer/tasks/virtualenv/venv.yml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • ansible/roles/ovos_installer/tasks/docker/composer.yml
🧰 Additional context used

@goldyfruit
Copy link
Member

@suvanbanerjee have you tried this PR?

@goldyfruit goldyfruit merged commit 44d854b into OpenVoiceOS:main Oct 11, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request translation Add or fix translation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: use new autoconfigure command
3 participants