changeset 50:308c89235a2e

doc update
author Amine SEHILI <amine.sehili@gmail.com>
date Mon, 07 Mar 2016 20:58:55 +0100
parents 809df9157e1a
children a9cdbaaa3ce0
files INSTALL auditok/util.py doc/conf.py doc/index.rst setup.py
diffstat 5 files changed, 44 insertions(+), 62 deletions(-) [+]
line wrap: on
line diff
--- a/INSTALL	Sun Mar 06 14:57:03 2016 +0100
+++ b/INSTALL	Mon Mar 07 20:58:55 2016 +0100
@@ -1,3 +1,9 @@
+### Install via pip
 
+    sudo pip install auditok
 
-python setup.py install
+### Install the latest version on Github
+
+    git clone https://github.com/amsehili/auditok.git
+    cd auditok
+    sudo python setup.py install
--- a/auditok/util.py	Sun Mar 06 14:57:03 2016 +0100
+++ b/auditok/util.py	Mon Mar 07 20:58:55 2016 +0100
@@ -269,13 +269,11 @@
         `max_time`, `mt` : *(float)*
             maximum time (in seconds) to read. Default behavior: read until there is no more data
             available. 
-        
          
         `record`, `rec` : *(bool)*
             save all read data in cache. Provide a navigable object which boasts a `rewind` method.
             Default = False.
         
-        
         `block_dur`, `bd` : *(float)*
             processing block duration in seconds. This represents the quantity of audio data to return 
             each time the :func:`read` method is invoked. If `block_dur` is 0.025 (i.e. 25 ms) and the sampling
@@ -291,12 +289,10 @@
             is given, `hop_dur` will be set to `block_dur` which means that there will be no overlap
             between two consecutively read blocks.
              
-          
         `block_size`, `bs` : *(int)*
             number of samples to read each time the `read` method is called. Default: a block size
             that represents a window of 10ms, so for a sampling rate of 16000, the default `block_size`
             is 160 samples, for a rate of 44100, `block_size` = 441 samples, etc.
-            
         
         `hop_size`, `hs` : *(int)*
             determines the number of overlapping samples between two adjacent read windows. For a
@@ -439,12 +435,12 @@
             ads.close()
             data = b''.join(data)
             assert len(data) == int(ads.get_sampling_rate() * 2.25 * ads.get_sample_width() * ads.get_channels())
-        
         """
         
+        # copy user's dicionary (shallow copy)
+        kwargs = kwargs.copy()
         
-        
-        
+        # check and normalize keyword arguments
         ADSFactory._check_normalize_args(kwargs)
         
         block_dur = kwargs.pop("bd")
@@ -455,9 +451,6 @@
         audio_source = kwargs.pop("asrc")
         filename = kwargs.pop("fn")
         data_buffer = kwargs.pop("db")
-        
-        # normalize db sr, sw and ch
-        
         record = kwargs.pop("rec")
         
         # Case 1: an audio source is supplied
@@ -574,10 +567,8 @@
             
         def read(self):
             return self.audio_source.read(self.block_size)
-        
-        
-    
-    
+
+
     class ADSDecorator(AudioDataSource):
         """
         Base decorator class for AudioDataSource objects.
@@ -597,7 +588,6 @@
             self.get_sample_width = self.ads.get_sample_width
             self.get_channels = self.ads.get_channels
         
-        
         def is_rewindable(self):
             return self.ads.is_rewindable
             
@@ -614,14 +604,12 @@
                 self.ads.open()
                 self._reinit()
             
-        
         @abstractmethod
         def _reinit(self):
             pass            
         
         
     class OverlapADS(ADSDecorator):
-        
         """
         A class for AudioDataSource objects that can read and return overlapping audio frames
         """
@@ -640,8 +628,6 @@
             def _get_block_size():
                 return self._actual_block_size
             
-            #self.get_block_size = _get_block_size
-            
             
         def _read_first_block(self):
             # For the first call, we need an entire block of size 'block_size'
@@ -675,8 +661,7 @@
                 self._cache = None
                 
             return block
-                
-                    
+
         def read(self):
             pass
         
@@ -690,9 +675,9 @@
                                self.get_sample_width() * \
                                self.get_channels()
             self.read = self._read_first_block
-     
-    
-    
+
+
+
     class LimiterADS(ADSDecorator):
         """
         A class for AudioDataSource objects that can read a fixed amount of data.
@@ -724,10 +709,9 @@
                                   self.get_sample_width() * \
                                   self.get_channels()
             self._total_read_bytes = 0
+
             
-            
-      
-    
+
     class RecorderADS(ADSDecorator):
         """
         A class for AudioDataSource objects that can record all audio data they read,
@@ -739,11 +723,9 @@
             
             self._reinit()
             
-            
         def read(self):
             pass
         
-        
         def _read_and_rec(self):
             # Read and save read data
             block = self.ads.read()
@@ -756,8 +738,7 @@
         def _read_simple(self):
             # Read without recording
             return self.ads.read()
-            
-        
+
         def rewind(self):
             if self._record:
                 # If has been recording, create a new BufferAudioSource
@@ -798,13 +779,8 @@
             except TypeError:
                 # work for 'str' in python 2 and python 3
                 return ''.join(data)
-                
-        
 
 
-                
-            
-
 class AudioEnergyValidator(DataValidator):
     """
     The most basic auditok audio frame validator.
@@ -813,12 +789,13 @@
     otherwise.
     
     :Parameters:
-    `sample_width` : int
+    
+    `sample_width` : *(int)*
         Number of bytes of one audio sample. This is used to convert data from `basestring` or `Bytes` to
         an array of floats.
         
-    `energy_threshold` : float
-        A threshold used to check whether an input data buffer is valid. 
+    `energy_threshold` : *(float)*
+        A threshold used to check whether an input data buffer is valid.
     """
     
     
@@ -885,16 +862,15 @@
         
         :Parameters:
         
-            `data` : either a string or a Bytes buffer
-                `data` is converted into a numerical arra using the `sample_width`
-                given in the constructor.
+        `data` : either a *string* or a *Bytes* buffer
+            `data` is converted into a numerical array using the `sample_width`
+            given in the constructor.
         
         :Retruns:
         
-            True if `log_energy` > `energy_threshold`, False otherwise.
+        True if `log_energy` >= `energy_threshold`, False otherwise.
         """
         
-        
         signal = AudioEnergyValidator._convert(data, self.sample_width)
         return AudioEnergyValidator._signal_log_energy(signal) >= self._energy_threshold
     
@@ -903,7 +879,4 @@
     
     def set_energy_threshold(self, threshold):
         self._energy_threshold = threshold
-        
-    
-    
-        
\ No newline at end of file
+
--- a/doc/conf.py	Sun Mar 06 14:57:03 2016 +0100
+++ b/doc/conf.py	Mon Mar 07 20:58:55 2016 +0100
@@ -51,7 +51,7 @@
 
 # General information about the project.
 project = u'auditok'
-copyright = u'2015, Amine Sehili'
+copyright = u'2015-2016, Amine Sehili'
 author = u'Amine Sehili'
 
 # The version info for the project you're documenting, acts as replacement for
@@ -59,9 +59,9 @@
 # built documents.
 #
 # The short X.Y version.
-version = '0.1.4'
+version = '0.1.5'
 # The full version, including alpha/beta/rc tags.
-release = '0.1.4'
+release = '0.1.5'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
@@ -112,7 +112,7 @@
 
 # The theme to use for HTML and HTML Help pages.  See the documentation for
 # a list of builtin themes.
-html_theme = 'sphinxdoc'
+#html_theme = 'sphinxdoc'
 
 
 # on_rtd is whether we are on readthedocs.org
--- a/doc/index.rst	Sun Mar 06 14:57:03 2016 +0100
+++ b/doc/index.rst	Mon Mar 07 20:58:55 2016 +0100
@@ -19,13 +19,13 @@
 
 However, if you want more features, the following packages are needed:
 
-- `Pydub <https://github.com/jiaaro/pydub>`_ : read audio files of popular audio formats (ogg, mp3, etc.) or extract audio from a video file
+- `Pydub <https://github.com/jiaaro/pydub>`_ : read audio files in popular audio formats (ogg, mp3, etc.) or extract audio from a video file.
 
-- `PyAudio <http://people.csail.mit.edu/hubert/pyaudio/>`_ : read audio data from the microphone and play back detections
+- `PyAudio <http://people.csail.mit.edu/hubert/pyaudio/>`_ : read audio data from the microphone and play back detections.
 
-- `matplotlib <http://matplotlib.org/>`_ : plot audio signal and detections (see figures above)
+- `matplotlib <http://matplotlib.org/>`_ : plot audio signal and detections (see figures above).
 
-- `numpy <http://www.numpy.org>`_ : required by matplotlib. Also used for math operations instead of standard python if available
+- `numpy <http://www.numpy.org>`_ : required by matplotlib. Also used for math operations instead of standard python if available.
 
 - Optionally, you can use **sox** or **parecord** for data acquisition and feed **auditok** using a pipe.
 
@@ -34,12 +34,17 @@
 
 .. code:: bash
 
+    sudo pip install auditok
+
+
+or install the latest version on Github:
+
+.. code:: bash
+
     git clone https://github.com/amsehili/auditok.git
     cd auditok
     sudo python setup.py install
 
-
-
 Getting started
 ---------------
 
@@ -50,7 +55,6 @@
        Command-line Usage Guide <cmdline.rst>
        API Tutorial <apitutorial.rst>
 
-
 API Reference
 -------------
 
@@ -62,7 +66,6 @@
        auditok.io <io.rst>
        auditok.dataset <dataset.rst>
 
-
 Indices and tables
 ==================
 * :ref:`genindex`
--- a/setup.py	Sun Mar 06 14:57:03 2016 +0100
+++ b/setup.py	Mon Mar 07 20:58:55 2016 +0100
@@ -10,7 +10,7 @@
    with open('auditok/__init__.py', 'rt') as f:
       version = str(ast.literal_eval(_version_re.search(
       f.read()).group(1)))
-      long_desc = open('quickstart.rst', 'rt').read() 
+      long_desc = open('doc/index.rst', 'rt').read() 
 
 else:
    with open('auditok/__init__.py', 'rb') as f: