-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8670c87
commit 624f305
Showing
8 changed files
with
240 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
name: Publish to PyPI and Create Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
workflow_dispatch: | ||
|
||
jobs: | ||
publish: | ||
permissions: | ||
id-token: write | ||
contents: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install poetry | ||
poetry install | ||
- name: Version bump | ||
id: version | ||
run: | | ||
if [[ "v$(poetry version --short)" == "$(git describe --tags --always --abbrev=0)" ]]; then | ||
poetry version patch | ||
git add pyproject.toml | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "MarkParker5" | ||
git commit -m "Version bump v$(poetry version --short)" | ||
git push | ||
echo Version bumped to $(poetry version --short) | ||
fi | ||
echo Using version $(poetry version --short) | ||
echo VERSION="v$(poetry version --short)" >> $GITHUB_OUTPUT | ||
- name: Build distribution | ||
id: build | ||
run: | | ||
poetry build | ||
echo FILE="$(ls dist/*.whl -U | head -1)" >> $GITHUB_OUTPUT | ||
- name: Publish to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
password: ${{ secrets.PYPI_API_TOKEN }} | ||
|
||
- name: Create tag | ||
uses: rickstaa/action-create-tag@v1 | ||
with: | ||
tag: ${{ steps.version.outputs.VERSION }} | ||
|
||
- name: Generate changelog | ||
id: changelog | ||
run: | | ||
changelog=$(git log --pretty=format:"- %s" "${{ steps.version.outputs.VERSION }}..HEAD") | ||
- name: Create GitHub Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }} | ||
with: | ||
tag_name: ${{ steps.version.outputs.VERSION }} | ||
release_name: Release ${{ steps.version.outputs.VERSION }} | ||
body: ${{ steps.changelog.outputs.changelog }} | ||
draft: false | ||
prerelease: false | ||
|
||
- name: Upload .whl file | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ${{ steps.build.outputs.FILE }} | ||
asset_name: ${{ steps.build.outputs.FILE }} | ||
asset_content_type: application/zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[tool.poetry] | ||
name = "stark-place" | ||
version = "1.0.0" | ||
description = "S.T.A.R.K. Platform Library And Community Extensions" | ||
authors = ["Mark Parker <[email protected]>"] | ||
license = "CC BY-NC-SA 4.0" | ||
readme = "README.md" | ||
packages = [{include = "stark_place"}] | ||
homepage = "https://pypi.org/project/stark-place/" | ||
repository = "https://github.com/MarkParker5/STARK-PLACE" | ||
documentation = "https://stark.markparker.me" | ||
keywords = ["python", "open-source", "natural-language-processing", "framework", "cross-platform", "natural-language", "voice", "voice-commands", "python3", "voice-recognition", "speech-recognition", "speech-to-text", "community-project", "voice-assistant", "voice-interface", "NLP", "machine-learning", "AI", "text-analysis", "stark", "stark-place", "stark-engine", "mark parker"] | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.10" | ||
|
||
[tool.poetry.group.dev.dependencies] | ||
pytest = "^7.4.2" | ||
mypy = "^1.5.1" | ||
pytest-asyncio = "^0.21.1" | ||
pytest-trio = "^0.8.0" | ||
pytest-repeat = "^0.9.1" | ||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .general_manager import general_manager |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from stark import CommandsManager | ||
|
||
|
||
general_manager = CommandsManager() | ||
# general_manager.extend(...) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import anyio | ||
from stark import run, CommandsManager, Response | ||
from stark.core import ResponseHandler | ||
from stark.core.types import Word | ||
from stark.interfaces.vosk import VoskSpeechRecognizer | ||
from stark.interfaces.silero import SileroSpeechSynthesizer | ||
|
||
|
||
VOSK_MODEL_URL = "YOUR_CHOSEN_VOSK_MODEL_URL" | ||
SILERO_MODEL_URL = "YOUR_CHOSEN_SILERO_MODEL_URL" | ||
|
||
recognizer = VoskSpeechRecognizer(model_url=VOSK_MODEL_URL) | ||
synthesizer = SileroSpeechSynthesizer(model_url=SILERO_MODEL_URL) | ||
|
||
manager = CommandsManager() | ||
|
||
@manager.new('hello', hidden=True) | ||
def hello_context(**params): | ||
voice = text = f'Hi, {params["name"]}!' | ||
return Response(text=text, voice=voice) | ||
|
||
@manager.new('bye', hidden=True) | ||
def bye_context(name: Word, handler: ResponseHandler): | ||
handler.pop_context() | ||
return Response(text=f'Bye, {name}!') | ||
|
||
@manager.new('hello $name:Word') | ||
def hello(name: Word): | ||
text = voice = f'Hello, {name}!' | ||
return Response( | ||
text=text, | ||
voice=voice, | ||
commands=[hello_context, bye_context], | ||
parameters={'name': name} | ||
) | ||
|
||
async def main(): | ||
await run(manager, recognizer, synthesizer) | ||
|
||
if __name__ == '__main__': | ||
anyio.run(main) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import asyncer | ||
from stark import CommandsContext, CommandsManager, Response | ||
from stark.interfaces.protocols import SpeechRecognizer, SpeechSynthesizer | ||
from stark.interfaces.vosk import VoskSpeechRecognizer | ||
from stark.interfaces.silero import SileroSpeechSynthesizer | ||
from stark.voice_assistant import VoiceAssistant | ||
from stark.general.blockage_detector import BlockageDetector | ||
|
||
|
||
VOSK_MODEL_URL = "YOUR_CHOSEN_VOSK_MODEL_URL" | ||
SILERO_MODEL_URL = "YOUR_CHOSEN_SILERO_MODEL_URL" | ||
|
||
recognizer = VoskSpeechRecognizer(model_url=VOSK_MODEL_URL) | ||
synthesizer = SileroSpeechSynthesizer(model_url=SILERO_MODEL_URL) | ||
|
||
manager = CommandsManager() | ||
|
||
@manager.new('hello') | ||
async def hello_command() -> Response: | ||
text = voice = 'Hello, world!' | ||
return Response(text=text, voice=voice) | ||
|
||
async def run( | ||
manager: CommandsManager, | ||
speech_recognizer: SpeechRecognizer, | ||
speech_synthesizer: SpeechSynthesizer | ||
): | ||
async with asyncer.create_task_group() as main_task_group: | ||
context = CommandsContext( | ||
task_group = main_task_group, | ||
commands_manager = manager | ||
) | ||
voice_assistant = VoiceAssistant( | ||
speech_recognizer = speech_recognizer, | ||
speech_synthesizer = speech_synthesizer, | ||
commands_context = context | ||
) | ||
speech_recognizer.delegate = voice_assistant | ||
context.delegate = voice_assistant | ||
# context.fallback_command = fallback_command | ||
|
||
main_task_group.soonify(speech_recognizer.start_listening)() | ||
main_task_group.soonify(context.handle_responses)() | ||
|
||
detector = BlockageDetector() | ||
main_task_group.soonify(detector.monitor)() | ||
|
||
async def main(): | ||
await run(manager, recognizer, synthesizer) | ||
|
||
if __name__ == '__main__': | ||
asyncer.runnify(main)() # or anyio.run(main), same thing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import anyio | ||
from stark import run, CommandsManager, Response | ||
from stark.interfaces.vosk import VoskSpeechRecognizer | ||
from stark.interfaces.silero import SileroSpeechSynthesizer | ||
|
||
|
||
VOSK_MODEL_URL = "YOUR_CHOSEN_VOSK_MODEL_URL" | ||
SILERO_MODEL_URL = "YOUR_CHOSEN_SILERO_MODEL_URL" | ||
|
||
recognizer = VoskSpeechRecognizer(model_url=VOSK_MODEL_URL) | ||
synthesizer = SileroSpeechSynthesizer(model_url=SILERO_MODEL_URL) | ||
|
||
manager = CommandsManager() | ||
|
||
@manager.new('hello') | ||
async def hello_command() -> Response: | ||
text = voice = 'Hello, world!' | ||
return Response(text=text, voice=voice) | ||
|
||
async def main(): | ||
await run(manager, recognizer, synthesizer) | ||
|
||
if __name__ == '__main__': | ||
anyio.run(main) |