-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix async bugs - Update documentation and test script
* Async bugs: call the play function async from test script * Test script: more intuitive example of test script
- Loading branch information
1 parent
1310e1d
commit 2a3c6b3
Showing
5 changed files
with
67 additions
and
189 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 |
---|---|---|
|
@@ -136,6 +136,3 @@ dmypy.json | |
|
||
# Cython debug symbols | ||
cython_debug/ | ||
|
||
# Dev realated files | ||
dev/ |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,3 +1,46 @@ | ||
import nava.functions as nvf | ||
import asyncio | ||
import nava.functions as nv | ||
|
||
nvf.play("test/clear.wav", is_async=False, loop=False) | ||
|
||
async def test_print(): | ||
""" | ||
Simple function printing hello world async | ||
:return: None | ||
""" | ||
while True: | ||
print("Hello, World!") | ||
await asyncio.sleep(0.1) | ||
|
||
async def test_play(): | ||
""" | ||
Simple function playing sound async (must provide path to file) | ||
:return: None | ||
""" | ||
play_task = asyncio.create_task(nv.play("test/clear.wav", is_async=True)) | ||
print_task = asyncio.create_task(test_print()) | ||
|
||
await play_task | ||
|
||
if __name__ == "__main__": | ||
asyncio.run(test_play()) | ||
""" | ||
How to run? Make sure you're in the project root | ||
directory. Then, pass the script to Python interpreter | ||
like below: | ||
> python -m test.main | ||
The result in async mode with 0.1 second delay is as follows: | ||
Hello, World! | ||
Hello, World! | ||
Hello, World! | ||
Hello, World! | ||
Hello, World! | ||
Hello, World! | ||
Hello, World! | ||
Hello, World! | ||
Hello, World! | ||
In the meantime you should be able to hear the sound. The actual | ||
number of hello worlds depend on the voice length and the delay value. | ||
""" |