changeset 199:f6ac8dbea102

Implement play in AudioRegion
author Amine Sehili <amine.sehili@gmail.com>
date Wed, 08 May 2019 20:12:31 +0100
parents 6e574fa1b573
children 2e560bf4b2c0
files auditok/core.py
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/auditok/core.py	Mon May 06 18:43:34 2019 +0100
+++ b/auditok/core.py	Wed May 08 20:12:31 2019 +0100
@@ -10,7 +10,7 @@
 """
 import os
 from auditok.util import AudioDataSource, DataValidator, AudioEnergyValidator
-from auditok.io import check_audio_data, to_file
+from auditok.io import check_audio_data, to_file, player_for
 
 __all__ = ["split", "AudioRegion", "StreamTokenizer"]
 
@@ -271,6 +271,11 @@
     def ch(self):
         return self._channels
 
+    def play(self, player=None, progress_bar=False):
+        if player is None:
+            player = player_for(self)
+        player.play(self, progress_bar=progress_bar)
+
     def save(self, file, format=None, exists_ok=True, **audio_parameters):
         """Save audio region to file.