-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from letuananh/dev
update media documentation
- Loading branch information
Showing
7 changed files
with
88 additions
and
54 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
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
.. _recipe_media: | ||
|
||
Media processing recipes | ||
======================== | ||
|
||
:mod:`Media module <speach.media>` can be used to process audio and video files (converting, merging, cutting, et cetera). | ||
``speach.media`` use ffmpeg underneath. | ||
|
||
:mod:`Media module <speach.media>` requires ``ffmpeg``, for installation guide please refer to :ref:`install_ffmpeg`. | ||
|
||
Sample code | ||
----------- | ||
|
||
Just import media module from speach library to start using it | ||
|
||
>>> from speach import media | ||
|
||
converting the wave file ``test.wav`` in Documents folder into OGG format ``test.ogg`` | ||
|
||
>>> media.convert("~/Documents/test.wav", "~/Documents/test.ogg") | ||
|
||
cutting ``test.wav`` from the beginning to 00:00:10 and write output to ``test_before10.ogg`` | ||
|
||
>>> media.cut("test.wav", "test_before10.ogg", to_ts="00:00:10") | ||
|
||
cutting ``test.wav`` from 00:00:15 to the end of the file and write output to ``test_after15.ogg`` | ||
|
||
>>> media.cut("test.wav", ELAN_DIR / "test_after15.ogg", from_ts="00:00:15") | ||
|
||
cutting ``test.wav`` from 00:00:15 to 00:00:15 and write output to ``test_10-15.ogg`` | ||
|
||
>>> media.cut(ELAN_DIR / "test.wav", ELAN_DIR / "test_10-15.ogg", from_ts="00:00:10", to_ts="00:00:15") | ||
|
||
Querying ffmpeg information | ||
--------------------------- | ||
|
||
>>> from speach import media | ||
>>> media.version() | ||
'4.2.4-1ubuntu0.1' | ||
>>> media.locate_ffmpeg() | ||
'/usr/bin/ffmpeg' | ||
|
||
Others | ||
------ | ||
|
||
For in-depth information and a complete API reference, please refer to :mod:`speach.media` API page. |
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 |
---|---|---|
|
@@ -8,4 +8,5 @@ Here are code snippets for common usecases of ``speach``. | |
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
elan | ||
recipe_elan | ||
recipe_media |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
.. _tut_media: | ||
|
||
Media processing tutorial | ||
========================= | ||
|
||
:mod:`Media module <speach.media>` can be used to process audio and video files (converting, merging, cutting, et cetera). | ||
``speach.media`` use ffmpeg underneath. | ||
|
||
.. _install_ffmpeg: | ||
|
||
Installing ffmpeg | ||
----------------- | ||
|
||
Linux | ||
~~~~~ | ||
|
||
It is very likely that your Linux distribution comes with a default ``ffmpeg`` package under ``/usr/bin/ffmpeg``. | ||
|
||
Windows | ||
~~~~~~~ | ||
|
||
.. note:: | ||
To be updated (download and install to ``C:\\Users\\<account_name>\\local\\ffmpeg\\ffmpeg.exe``) | ||
|
||
Mac OS | ||
~~~~~~ | ||
|
||
You can download ffmpeg binary file from https://ffmpeg.org and copy it to one of these folders | ||
|
||
- /Users/<account_name>/ffmpeg | ||
- /Users/<account_name>/bin/ffmpeg | ||
- /Users/<account_name>/local/ffmpeg | ||
- /Users/<account_name>/local/ffmpeg/ffmpeg | ||
|
||
and ``speach`` will find it automatically. |
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 |
---|---|---|
|
@@ -23,5 +23,7 @@ Module tutorials | |
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
elan | ||
media | ||
tut_media | ||
|
||
|
||
See :ref:`recipes` for code samples. |