Install using vpkg
vpkg get https://github.com/thecodrr/vave
Install using V
's builtin vpm
(you will need to import the module with: import thecodrr.vave
with this method of installation):
v install thecodrr.vave
Install using git
:
cd path/to/your/project
git clone https://github.com/thecodrr/vave
Then in the wherever you want to use it:
import thecodrr.vave //OR simply vave depending on how you installed
And that's it!
This library is in use in the vspeech (V Bindings for DeepSpeech) utility that uses Mozilla's DeepSpeech for Speech-to-Text. Do check that out as well.
Open a new WAV file in the specified mode. All mode supported by C.fopen
are supported (e.g. r
, rb
etc.)
mut wav := vave.open("/path/to/vave/file", "r") //open for reading
NOTES: The data is read into a byteptr
and needs to be manually freed each and everytime or it will cause a huge memory leak. This library has been tested with valgrind
and after freeing there is no other memory leak (if you find any, do report). I haven't implemented writing samples yet due to lack of time but its in my future plans.
WavFile
struct is used for reading/writing samples and other metadata. It is returned by vave.open
.
Read all the samples from the file in their raw form.
Read a specific amount of samples from the file.
Read only one sample from the file.
TODO
Close the file and free all associated resources.
Get total number of audio samples in the file.
Get total duration of the audio file.
Get the total length of sample bytes in the file.
Get total bytes per each sample.
Get the sample rate (samples per second).
Get the size of one sample()
Get the format of the WAV audio. Either PCM
, IEEE
, ALAW
,MULAW
or EXTENSIBLE
.
Get the total number of channels in the audio stream.
Get the bits per each sample.
Currently only the following formats are supported:
-
PCM
-
IEEE
-
ALAW
-
MULAW
-
EXTENSIBLE
Support it by joining stargazers for this repository. βor buy me a cup of coffee And follow me for my next creations! π€©
MIT License
Copyright (c) 2019 Abdullah Atta
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.