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:utterance filename #171

Merged
merged 1 commit into from
Oct 19, 2024
Merged

fix:utterance filename #171

merged 1 commit into from
Oct 19, 2024

Conversation

JarbasAl
Copy link
Member

@JarbasAl JarbasAl commented Oct 19, 2024

companion to OpenVoiceOS/ovos-dinkum-listener#140

the current default value in config is no longer valid

Summary by CodeRabbit

  • New Features

    • Updated the filename generation for saved utterances to enhance uniqueness by using an MD5 hash.
  • Documentation

    • Added comments for future updates and clarifications regarding the wake word listener settings.

companion to OpenVoiceOS/ovos-dinkum-listener#140

the current default value in config is no longer valid
@github-actions github-actions bot added the fix label Oct 19, 2024
Copy link
Contributor

coderabbitai bot commented Oct 19, 2024

Walkthrough

The pull request modifies the mycroft.conf configuration file, specifically updating the utterance_filename setting within the listener section. The filename generation format is changed from "{hash}-{uuid4}" to "{md5}-{uuid4}", which alters how saved utterance filenames are created. The configuration structure remains unchanged, with additional comments added for potential future updates and clarifications regarding the listener's functionality.

Changes

File Path Change Summary
ovos_config/mycroft.conf Updated utterance_filename from "{hash}-{uuid4}" to "{md5}-{uuid4}" in the listener section; added comments for future updates.

Possibly related PRs

  • Document utterance_filename #157: The changes in this PR directly relate to the utterance_filename setting in the mycroft.conf file, as it discusses the introduction of customizable filename features, which aligns with the modification made in the main PR.

Poem

In the world of config, a change took flight,
From hash to MD5, filenames shine bright.
With each little utterance, a new name to find,
A leap for the listener, so clever and kind.
Hopping through settings, with joy we embrace,
A future of clarity in this digital space! 🐇✨


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

codecov bot commented Oct 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (dev@12da5ad). Learn more about missing BASE report.

Additional details and impacted files
@@          Coverage Diff          @@
##             dev    #171   +/-   ##
=====================================
  Coverage       ?   0.00%           
=====================================
  Files          ?      10           
  Lines          ?     877           
  Branches       ?       0           
=====================================
  Hits           ?       0           
  Misses         ?     877           
  Partials       ?       0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions github-actions bot added fix and removed fix labels Oct 19, 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 (1)
ovos_config/mycroft.conf (1)

Line range hint 458-461: Review related utterance saving settings

While updating the utterance_filename format, it's important to review the related settings:

  1. "save_utterances": false, (line 461): This setting is currently set to false, which means utterances are not being saved. If the intention is to use the new filename format, make sure to set this to true when needed.

  2. "save_path": "/tmp", (line 459): This line is commented out, but it specifies where utterances would be saved. Ensure that the desired save path is correctly set and uncommented if save_utterances is enabled.

Consider adding a comment explaining the new utterance_filename format for better documentation:

    "utterance_filename": "{md5}-{uuid4}",
+   // Generates a filename using an MD5 hash of the transcription and a random UUID

Also applies to: 469-471

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 12da5ad and 677f311.

📒 Files selected for processing (1)
  • ovos_config/mycroft.conf (1 hunks)
🧰 Additional context used
🔇 Additional comments (2)
ovos_config/mycroft.conf (2)

Line range hint 1-1000: Overall configuration review

The change to the utterance_filename setting is the primary modification in this configuration file. The rest of the configuration remains unchanged and appears to be well-structured.

The update to use an MD5 hash in the filename is a reasonable change that provides more specificity in the filename generation process. The configuration file as a whole seems to be comprehensive and well-organized, covering various aspects of the OVOS system.

To ensure the configuration file is valid JSON, we can run a quick check:

#!/bin/bash
# Validate JSON structure of the configuration file
jq . ovos_config/mycroft.conf > /dev/null
if [ $? -eq 0 ]; then
    echo "Configuration file is valid JSON"
else
    echo "Error: Configuration file is not valid JSON"
fi

This will help catch any potential syntax errors that might have been introduced during the update.


473-473: Update to utterance filename format

The utterance_filename setting has been changed from "{hash}-{uuid4}" to "{md5}-{uuid4}". This change specifies that an MD5 hash should be used instead of a generic hash.

This change provides a more specific and standardized approach to generating filenames for saved utterances. MD5 is a well-known hashing algorithm, which can lead to more consistent and predictable filename generation.

However, it's worth noting a few points:

  1. MD5 is considered cryptographically weak, but for filename generation purposes, it should be sufficient.
  2. Ensure that any code or scripts that rely on the old filename format are updated accordingly.

To ensure this change doesn't break any existing functionality, let's check for any references to the old format:

@JarbasAl JarbasAl merged commit d9a8abb into dev Oct 19, 2024
10 checks passed
@JarbasAl JarbasAl deleted the JarbasAl-patch-1 branch October 19, 2024 12:07
JarbasAl added a commit to OpenVoiceOS/ovos-dinkum-listener that referenced this pull request Oct 19, 2024
backwards compat check wasnt quite right in #140

```
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]: 2024-10-19 08:04:47.463 - voice - ovos_dinkum_listener.service:_stt_audio:747 - ERROR - Error while saving STT audio
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]: Traceback (most recent call last):
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:   File "/home/goldyfruit/.venvs/ovos/lib64/python3.11/site-packages/ovos_dinkum_listener/service.py", line 742, in _stt_audio
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:     stt_context["filename"] = self._save_stt(audio_bytes, stt_context)
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:   File "/home/goldyfruit/.venvs/ovos/lib64/python3.11/site-packages/ovos_dinkum_listener/service.py", line 707, in _save_stt
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:     filename = formatter.format(utterance_filename)
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:   File "/home/goldyfruit/.venvs/ovos/lib64/python3.11/site-packages/ovos_dinkum_listener/_util.py", line 107, in format
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:     fmtkw = self._build_fmtkw(template, **kwargs)
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:   File "/home/goldyfruit/.venvs/ovos/lib64/python3.11/site-packages/ovos_dinkum_listener/_util.py", line 91, in _build_fmtkw
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:     fmtkw[key] = builder()
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:                  ^^^^^^^^^
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:   File "/home/goldyfruit/.venvs/ovos/lib64/python3.11/site-packages/ovos_dinkum_listener/service.py", line 705, in transcription_md5
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:     return hash_sentence(text)
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:            ^^^^^^^^^^^^^^^^^^^
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:   File "/home/goldyfruit/.venvs/ovos/lib64/python3.11/site-packages/ovos_plugin_manager/utils/tts_cache.py", line 20, in hash_sentence
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:     encoded_sentence = sentence.encode("utf-8", "ignore")
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:                        ^^^^^^^^^^^^^^^
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]: AttributeError: 'NoneType' object has no attribute 'encode'

```

also needs OpenVoiceOS/ovos-config#171
JarbasAl added a commit to OpenVoiceOS/ovos-dinkum-listener that referenced this pull request Oct 19, 2024
* fix:save utterances

backwards compat check wasnt quite right in #140

```
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]: 2024-10-19 08:04:47.463 - voice - ovos_dinkum_listener.service:_stt_audio:747 - ERROR - Error while saving STT audio
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]: Traceback (most recent call last):
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:   File "/home/goldyfruit/.venvs/ovos/lib64/python3.11/site-packages/ovos_dinkum_listener/service.py", line 742, in _stt_audio
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:     stt_context["filename"] = self._save_stt(audio_bytes, stt_context)
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:   File "/home/goldyfruit/.venvs/ovos/lib64/python3.11/site-packages/ovos_dinkum_listener/service.py", line 707, in _save_stt
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:     filename = formatter.format(utterance_filename)
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:   File "/home/goldyfruit/.venvs/ovos/lib64/python3.11/site-packages/ovos_dinkum_listener/_util.py", line 107, in format
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:     fmtkw = self._build_fmtkw(template, **kwargs)
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:   File "/home/goldyfruit/.venvs/ovos/lib64/python3.11/site-packages/ovos_dinkum_listener/_util.py", line 91, in _build_fmtkw
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:     fmtkw[key] = builder()
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:                  ^^^^^^^^^
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:   File "/home/goldyfruit/.venvs/ovos/lib64/python3.11/site-packages/ovos_dinkum_listener/service.py", line 705, in transcription_md5
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:     return hash_sentence(text)
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:            ^^^^^^^^^^^^^^^^^^^
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:   File "/home/goldyfruit/.venvs/ovos/lib64/python3.11/site-packages/ovos_plugin_manager/utils/tts_cache.py", line 20, in hash_sentence
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:     encoded_sentence = sentence.encode("utf-8", "ignore")
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:                        ^^^^^^^^^^^^^^^
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]: AttributeError: 'NoneType' object has no attribute 'encode'

```

also needs OpenVoiceOS/ovos-config#171

* Update requirements.txt
@coderabbitai coderabbitai bot mentioned this pull request Oct 23, 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.

1 participant