Metadata-Version: 2.4
Name: martypy
Version: 3.8.0
Summary: Python library for Marty the Robot V1 and V2
Home-page: http://github.com/robotical/martypy
Author: Robotical
Author-email: hello@robotical.io
Maintainer: Robotical
Maintainer-email: hello@robotical.io
License: Apache 2.0
Keywords: ros,robot,marty,marty the robot,robotical
Classifier: Development Status :: 5 - Production/Stable
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Operating System :: OS Independent
Classifier: License :: OSI Approved :: Apache Software License
Description-Content-Type: text/markdown
License-File: LICENSE.md
Requires-Dist: pyserial
Requires-Dist: packaging
Requires-Dist: requests
Requires-Dist: pydub
Requires-Dist: audioop-lts; python_version >= "3.13"
Provides-Extra: tests
Requires-Dist: pytest; extra == "tests"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: license-file
Dynamic: maintainer
Dynamic: maintainer-email
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: summary

# martypy

Python library to communicate with Marty the Robot V1 and V2 by Robotical

[See the API Documentation](https://userguides.robotical.io/martyv2/documentation/python_function_reference)

To regenerate documentation:
- pip install -r dev-requirements.txt
- pydoc-markdown --server --open
- markdown_mmd api-documentation-edited.md -t dokuwiki -o docs-wiki.wiki
OR, automatically:
- run docgen.bat (or docgen.sh on Mac/Linux) from Python environment (will also create a docs-wiki.wiki file with the dokuwiki format)

### NOTE: Make sure `pandoc` is installed on your system to generate the dokuwiki documentation. You can install `pandoc` from [here](https://pandoc.org/installing.html)

## How to run example scripts

If you cloned the repository or downloaded the source code to try the [example scripts](examples),
you will need to make sure you have MartyPy installed before you can run the examples.

The easiest way to install MartyPy is with the `pip install martypy` script as explained in
[step 2 here](https://userguides.robotical.io/martyv2/userguides/python/setting_up_python_on_your_computer).

Once martypy is installed you can run each example using python.
The following (for the dance example) assumes you have connected your marty using the USB cable to a Windows computer

python example_dance.py USB

To run the sound example over WiFi when your Marty is connected on IP address 192.168.86.10, use:

python example_sound.py WiFi 192.168.0.10

If you would like to make modifications to the martypy library itself, it will be better to install
it from source using the command `pip install --editable /path/to/martypy/repo` (replacing
`/path/to/martypy/repo` as appropriate of course).

If you do not want to "`pip install`" the MartyPy library, you can add the following 4 lines at the
top (before any other code) of each script you want to run:

```python
import sys
import pathlib
cur_path = pathlib.Path(__file__).parent.resolve()
sys.path.append(str(cur_path.parent.resolve()))
```

## Speak and Translate

The Speak and Translate APIs use Robotical's online services and require an internet
connection. Speech synthesis and changing playback speed require FFmpeg on the
computer; `speak_on_computer` also needs a supported audio player (such as ffplay).

```python
my_marty.set_voice("FEMALE")        # Also MALE, KITTEN, ALIEN, GIANT, BOLT, STARLIGHT, WHIRLWIND
my_marty.set_voice_speed(1.5)       # 0.1 to 2; 1 is normal speed
my_marty.set_speech_language("fr") # Accent; does not translate the words
words = my_marty.translate("Hello", "fr")
my_marty.speak(words, blocking=True)  # Marty's speaker
my_marty.speak_on_computer(words)     # Computer speaker; waits until finished
print(my_marty.get_language())        # Computer language name
```

Speech settings persist until changed. Explicit `voice`, `language` and `speed`
arguments to `speak`/`speak_on_computer` override them for that call. Translation
returns text, not speech, and raises an error if its online request fails. In Blocks,
the matching calls use the existing browser extensions, and `get_language` reports
the editor's language instead of the computer's Python locale. Browser speech uses
the browser audio system, so it does not require a local FFmpeg installation.

## Publishing

- Update version: keep `setup.py` and `martypy/__init__.py` in sync and update `CHANGES.md`.
- Push changes: commit and push to GitHub.
- Publish: in GitHub Actions, manually run the "Publish to PyPI" workflow.
