Skip to content

Commit

Permalink
bump python version and test 3.10+
Browse files Browse the repository at this point in the history
  • Loading branch information
bejager committed May 2, 2024
1 parent 6e2fb0d commit 10c65c1
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 15 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/python-demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
python-version: [ '3.8' ] # '3.9', '3.10', '3.11', '3.12' ]
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
include:
- os: ubuntu-latest
install_dep: sudo apt install libportaudio2
- os: windows-latest
- os: macos-latest
install_dep: brew update && brew install portaudio --HEAD

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
python-version: [ '3.8' ] # , '3.9', '3.10', '3.11', '3.12' ]
python-version: [ '3.8' , '3.9', '3.10', '3.11', '3.12' ]

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion binding/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Orca is:

## Compatibility

- Python 3.7+
- Python 3.8+
- Runs on Linux (x86_64), macOS (x86_64, arm64), Windows (x86_64), Raspberry Pi (5, 4, 3), and NVIDIA Jetson Nano.

## Installation
Expand Down
2 changes: 1 addition & 1 deletion demo/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Orca is an on-device text-to-speech engine producing high-quality, realistic, sp

## Compatibility

- Python 3.7+
- Python 3.8+
- Runs on Linux (x86_64), macOS (x86_64, arm64), Windows (x86_64), Raspberry Pi (5, 4, 3), and NVIDIA Jetson Nano.

## Installation
Expand Down
16 changes: 10 additions & 6 deletions demo/python/_audio_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from queue import Queue
from typing import (
Any,
Dict,
Optional,
Sequence,
)

Expand All @@ -22,7 +24,11 @@


class StreamingAudioDevice:
def __init__(self, device_index: int) -> None:
def __init__(self, device_index: Optional[int] = None) -> None:
if device_index is None:
device_info = query_devices(kind="output")
device_index = int(device_info["index"])

self._device_index = device_index
self._queue: Queue[Sequence[int]] = Queue()

Expand Down Expand Up @@ -93,11 +99,9 @@ def terminate(self) -> None:
self._stream.stop()
self._stream.close()

@classmethod
def from_default_device(cls) -> 'StreamingAudioDevice':
device_info = query_devices(kind="output")
device_index = int(device_info["index"])
return cls(device_index=device_index)
@staticmethod
def list_output_devices() -> Dict[str, Any]:
return query_devices(kind="output")


__all__ = [
Expand Down
18 changes: 15 additions & 3 deletions demo/python/orca_demo_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,20 @@ def main(args: argparse.Namespace) -> None:
text = args.text_to_stream
tokens_per_second = args.tokens_per_second
audio_wait_chunks = args.audio_wait_chunks
audio_device_index = args.audio_device_index

try:
audio_device = StreamingAudioDevice.from_default_device()
audio_device = StreamingAudioDevice(device_index=audio_device_index)
# Some systems may have issues with PortAudio only when starting the audio device. Test it here.
audio_device.start(sample_rate=16000)
audio_device.terminate()
play_audio_callback = audio_device.play
except PortAudioError as e:
audio_device = None
print(traceback.format_exc())
print(
"WARNING: Failed to initialize audio device, see details above. Falling back to running "
"the demo without audio playback.\n")
audio_device = None

def play_audio_callback(pcm: Sequence[int]):
pass
Expand Down Expand Up @@ -154,5 +155,16 @@ def play_audio_callback(pcm: Sequence[int]):
type=int,
default=None,
help="Number of PCM chunks to wait before starting to play audio. Default: system-dependent.")
parser.add_argument(
"--show-audio-devices",
action="store_true",
help="Only list available audio output devices and exit")
parser.add_argument('--audio-device-index', type=int, default=None, help='Index of input audio device')

arg = parser.parse_args()

if arg.show_audio_devices:
print(StreamingAudioDevice.list_output_devices())
exit(0)

main(parser.parse_args())
main(arg)
2 changes: 1 addition & 1 deletion demo/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@
"orca_demo_streaming=pvorcademo.orca_demo_streaming:main",
],
),
python_requires=">=3.7",
python_requires=">=3.8",
keywords="Text-to-Speech, TTS, Speech Synthesis, Voice Generation, Speech Engine",
)

0 comments on commit 10c65c1

Please sign in to comment.