Metadata-Version: 2.1
Name: robobopy-audiostream
Version: 1.1.0
Summary: Robobo audio streaming library
Author: The Robobo Project
Author-email: info@theroboboproject.com
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: robobopy
Requires-Dist: pyaudio

# robobo-python-audio-stream

This library is required to use the audio streaming from the Smartphone's microphone in the Robobo.py library. It only runs in Android operating system.

## Installation

Download this repository to your computer and save it in the *robobo.by* folder. Then open a terminal window and type the two following commands:

```
pip install robobopy_audiostream
```


## Example

The following script shows an example of the basic usage of this library:

``` python
from robobopy_audiostream.RoboboAudio import RoboboAudio
from robobopy.Robobo import Robobo
import pyaudio

SERVER_IP = "ROBOBO_IP"

p = pyaudio.PyAudio()
FORMAT = pyaudio.paInt16
CHANNELS = 1
RATE = 44100
CHUNK = 1024

stream = p.open(format=FORMAT,
                channels=CHANNELS,
                rate=RATE,
                output=True,
                frames_per_buffer=CHUNK)


rob = Robobo(SERVER_IP)
rob.connect()

rob.setAudioStreamBitrate(RATE)
rob.startAudioStream()

audio = RoboboAudio(SERVER_IP)
audio.connect()

audio.syncAudioQueue()
while True:
    try:
        audioData = audio.getAudioWithMetadata()
        if not audioData is None:
            data, ts, snc = audioData
            stream.write(data)
        else:
            break
    except KeyboardInterrupt:
        break

rob.stopAudioStream()
audio.disconnect()

rob.disconnect()
```
