Skip to content

Commit

Permalink
refactor/ocp (#5)
Browse files Browse the repository at this point in the history
* refactor/ocp

* Update requirements.txt

---------

Co-authored-by: JarbasAi <[email protected]>
  • Loading branch information
NeonJarbas and JarbasAl authored Jan 8, 2024
1 parent ea5b7e2 commit 4b7c5aa
Show file tree
Hide file tree
Showing 28 changed files with 57 additions and 628 deletions.
34 changes: 34 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
dev.env
.dev_opts.json
.idea
*.code-workspace
*.pyc
*.swp
*~
mimic
/skills
pocketsphinx-python
*.egg-info/
build
dist
tornado.web
tornado.ioloop
mycroft/__version__.py
scripts/logs/*
logs/*
.coverage
/htmlcov
test/audio_accuracy/data
scripts/*.screen
doc/_build/
.installed
.mypy_cache
.vscode
.theia
.venv/

# Created by unit tests
test/unittests/skills/test_skill/settings.json
test_conf.json
.pytest_cache/
/.gtm/
4 changes: 1 addition & 3 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2024 Casimiro Ferreira

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -200,5 +200,3 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

=======================================================================
22 changes: 0 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,6 @@ If you like what you hear on SomaFM and want to help, please consider visiting t
* "play secret agent"
* "play metal detector"

# Platform support

- :heavy_check_mark: - tested and confirmed working
- :x: - incompatible/non-functional
- :question: - untested
- :construction: - partial support

| platform | status | tag | version | last tested |
|:---------------:|:----------:|:-----:|:-------:|:-----------:|
| [Chatterbox](https://hellochatterbox.com) | :question: | dev | | never |
| [HolmesV](https://github.com/HelloChatterbox/HolmesV) | :question: | dev | | never |
| [LocalHive](https://github.com/JarbasHiveMind/LocalHive) | :question: | dev | | never |
| [Mycroft Mark1](https://github.com/MycroftAI/enclosure-mark1) | :question: | dev | | never |
| [Mycroft Mark2](https://github.com/MycroftAI/hardware-mycroft-mark-II) | :question: | dev | | never |
| [NeonGecko](https://neon.ai) | :question: | dev | | never |
| [OVOS](https://github.com/OpenVoiceOS) | :question: | dev | | never |
| [Picroft](https://github.com/MycroftAI/enclosure-picroft) | :question: | dev | | never |
| [Plasma Bigscreen](https://plasma-bigscreen.org/) | :question: | dev | | never |

- `tag` - link to github release / branch / commit
- `version` - link to release/commit of platform repo where this was tested


## Credits
- JarbasAl
Expand Down
32 changes: 19 additions & 13 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
from os.path import join, dirname

import radiosoma

from ovos_utils import classproperty
from ovos_utils.ocp import MediaType, PlaybackType
from ovos_utils.parse import fuzzy_match
from ovos_workshop.skills.common_play import OVOSCommonPlaybackSkill, \
MediaType, PlaybackType, ocp_search, MatchConfidence, ocp_featured_media
from ovos_utils.process_utils import RuntimeRequirements
from ovos_utils import classproperty
from ovos_workshop.decorators.ocp import ocp_search, ocp_featured_media
from ovos_workshop.skills.common_play import OVOSCommonPlaybackSkill


class SomaFMSkill(OVOSCommonPlaybackSkill):
def __init__(self):
super().__init__("SomaFM")
self.supported_media = [MediaType.GENERIC,
MediaType.MUSIC,
MediaType.RADIO]

def __init__(self, *args, **kwargs):
self.supported_media = [MediaType.MUSIC, MediaType.RADIO]
self.skill_icon = join(dirname(__file__), "ui", "somafm.png")
super().__init__(*args, **kwargs)
self.load_ocp_keywords()

def load_ocp_keywords(self):
# register with OCP to help classifier pick MediaType.RADIO
self.register_ocp_keyword(MediaType.RADIO,
"radio_station", [s.title for s in radiosoma.get_stations()])
self.register_ocp_keyword(MediaType.RADIO,
"radio_streaming_provider",
["SomaFM", "Soma FM", "Soma"])

@classproperty
def runtime_requirements(self):
Expand Down Expand Up @@ -79,7 +89,7 @@ def search_somafm(self, phrase, media_type):
for ch in radiosoma.get_stations():
score = round(base_score + fuzzy_match(ch.title.lower(),
phrase.lower()) * 100)
if score <= MatchConfidence.AVERAGE_LOW.value:
if score < 50:
continue
yield {
"match_confidence": min(100, score),
Expand All @@ -93,7 +103,3 @@ def search_somafm(self, phrase, media_type):
"author": "SomaFM",
"length": 0
}


def create_skill():
return SomaFMSkill()
22 changes: 0 additions & 22 deletions build/lib/skill_ovos_somafm/CHANGELOG.md

This file was deleted.

204 changes: 0 additions & 204 deletions build/lib/skill_ovos_somafm/LICENSE

This file was deleted.

9 changes: 0 additions & 9 deletions build/lib/skill_ovos_somafm/MANIFEST.in

This file was deleted.

Loading

0 comments on commit 4b7c5aa

Please sign in to comment.