pytranscript


Namepytranscript JSON
Version 0.1.1 PyPI version JSON
download
home_pageNone
SummaryCLI to transcript and translate audio and video files
upload_time2024-03-23 19:56:43
maintainerNone
docs_urlNone
authorNone
requires_python>=3.12
licenseMIT License Copyright (c) [2024] [arnaud-ma] 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.
keywords transcript traduction audio video subtitles
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Pytranscript 🎙️

Pytranscript is a powerful Python library and command-line tool designed to seamlessly convert video or audio files into text and translate them into various languages. It acts as a simple yet effective wrapper around [Vosk](https://alphacephei.com/vosk/), [ffmpeg](https://ffmpeg.org/), and [deep-translator](https://pypi.org/project/deep-translator/), making the transcription and translation process straightforward.

## Prerequisites

Before using pytranscript, ensure you have the following dependencies installed:

- [ffmpeg](https://ffmpeg.org/download.html) for audio conversion.
- [vosk-models](https://alphacephei.com/vosk/models) required for speech recognition. You will have to specify to your specific model path in the `--model` argument.

## Installation

```bash
pip install pytranscript
```

## Usage

### Command Line

```bash
pytranscript INPUT_FILE [OPTIONS]
```

### Options

- `-m, --model` - Path to the Vosk model directory. Always required.
- `-o, --output` - Output file where the text will be saved. Default: input file name with `.txt` extension.
- `-li, --lang_input` - Language of the input / the model. Default: auto.
- `-lo --lang_input` - Language to translate the text to. Default: no translation.
- `-s, --start` - Start time of the audio to transcribe in seconds.
- `-e, --end` - End time of the audio to transcribe in seconds.
- `--max_size` - Will stop the transcription if the output file reaches the specified size in bytes. Takes precedence over the `--end` option.
- `--keep-wav` - Keep the converted audio wav file after the process is done.
- `-v, -verbosity` - Verbosity level. 0: no output, 1: only errors, 2: errors, info and progressbar, 3: debug. Default: 2.

## Example

The most basic usage is:

```bash
pytranscript video.mp4 -m vosk-model-en-us-aspire-0.2 -lo fr
```

Where `vosk-model-en-us-aspire-0.2` is the Vosk model directory. The text will be translated from English to French, and the output will be saved in a file named `video.txt`.

Using the `keep-wav` option can be useful if you want to do many transcriptions within the same file, allowing you to use the same `.wav` file for each transcription, thus saving conversion time.
 ⚠️ The `.wav` file is cropped according to the start and end time options.

### API

The API provides a Transcript object containing the time and text. The `translate` method can be used to get another Transcript object with the translated text. The output saved in a file in the cli is just the string
`str(transcript)`.

A reproduction of the previous example using the API:

```python
import pytranscript as pt

wav_file = pt.to_valid_wav('video.mp4', "video.wav", start=0, end=None)
transcript = pt.transcribe(wav_file, model='vosk-model-en-us-aspire-0.2', max_size=None)
transcript_fr = transcript.translate('fr')

with open('video.txt', 'w', encoding="utf8") as f:
    f.write(str(transcript_fr))
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pytranscript",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": "transcript, traduction, audio, video, subtitles",
    "author": null,
    "author_email": "arnaud-ma <arnaudma.code@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/0d/16/7d4b00ed27877f1b1f29e17a1b7960ddae723dd115eab265fdb89dacee8d/pytranscript-0.1.1.tar.gz",
    "platform": null,
    "description": "# Pytranscript \ud83c\udf99\ufe0f\r\n\r\nPytranscript is a powerful Python library and command-line tool designed to seamlessly convert video or audio files into text and translate them into various languages. It acts as a simple yet effective wrapper around [Vosk](https://alphacephei.com/vosk/), [ffmpeg](https://ffmpeg.org/), and [deep-translator](https://pypi.org/project/deep-translator/), making the transcription and translation process straightforward.\r\n\r\n## Prerequisites\r\n\r\nBefore using pytranscript, ensure you have the following dependencies installed:\r\n\r\n- [ffmpeg](https://ffmpeg.org/download.html) for audio conversion.\r\n- [vosk-models](https://alphacephei.com/vosk/models) required for speech recognition. You will have to specify to your specific model path in the `--model` argument.\r\n\r\n## Installation\r\n\r\n```bash\r\npip install pytranscript\r\n```\r\n\r\n## Usage\r\n\r\n### Command Line\r\n\r\n```bash\r\npytranscript INPUT_FILE [OPTIONS]\r\n```\r\n\r\n### Options\r\n\r\n- `-m, --model` - Path to the Vosk model directory. Always required.\r\n- `-o, --output` - Output file where the text will be saved. Default: input file name with `.txt` extension.\r\n- `-li, --lang_input` - Language of the input / the model. Default: auto.\r\n- `-lo --lang_input` - Language to translate the text to. Default: no translation.\r\n- `-s, --start` - Start time of the audio to transcribe in seconds.\r\n- `-e, --end` - End time of the audio to transcribe in seconds.\r\n- `--max_size` - Will stop the transcription if the output file reaches the specified size in bytes. Takes precedence over the `--end` option.\r\n- `--keep-wav` - Keep the converted audio wav file after the process is done.\r\n- `-v, -verbosity` - Verbosity level. 0: no output, 1: only errors, 2: errors, info and progressbar, 3: debug. Default: 2.\r\n\r\n## Example\r\n\r\nThe most basic usage is:\r\n\r\n```bash\r\npytranscript video.mp4 -m vosk-model-en-us-aspire-0.2 -lo fr\r\n```\r\n\r\nWhere `vosk-model-en-us-aspire-0.2` is the Vosk model directory. The text will be translated from English to French, and the output will be saved in a file named `video.txt`.\r\n\r\nUsing the `keep-wav` option can be useful if you want to do many transcriptions within the same file, allowing you to use the same `.wav` file for each transcription, thus saving conversion time.\r\n \u26a0\ufe0f The `.wav` file is cropped according to the start and end time options.\r\n\r\n### API\r\n\r\nThe API provides a Transcript object containing the time and text. The `translate` method can be used to get another Transcript object with the translated text. The output saved in a file in the cli is just the string\r\n`str(transcript)`.\r\n\r\nA reproduction of the previous example using the API:\r\n\r\n```python\r\nimport pytranscript as pt\r\n\r\nwav_file = pt.to_valid_wav('video.mp4', \"video.wav\", start=0, end=None)\r\ntranscript = pt.transcribe(wav_file, model='vosk-model-en-us-aspire-0.2', max_size=None)\r\ntranscript_fr = transcript.translate('fr')\r\n\r\nwith open('video.txt', 'w', encoding=\"utf8\") as f:\r\n    f.write(str(transcript_fr))\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) [2024] [arnaud-ma]  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.",
    "summary": "CLI to transcript and translate audio and video files",
    "version": "0.1.1",
    "project_urls": {
        "Documentation": "https://github.com/arnaud-ma/pytranscript#readme",
        "Issues": "https://github.com/arnaud-ma/pytranscript/issues",
        "Repository": "https://github.com/arnaud-ma/pytranscript",
        "Source": "https://github.com/arnaud-ma/pytranscript"
    },
    "split_keywords": [
        "transcript",
        " traduction",
        " audio",
        " video",
        " subtitles"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6711b3928ec034cd639be86919ce1c58bff36bb59ee4add188b472aeac2dd59e",
                "md5": "3215049bc01874eb3850b5706de8c3ec",
                "sha256": "7b6c0a9c00627498b07744ea01899869b9b0e3e4ac8d95431b78eca401c6aa54"
            },
            "downloads": -1,
            "filename": "pytranscript-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3215049bc01874eb3850b5706de8c3ec",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 8240,
            "upload_time": "2024-03-23T19:56:41",
            "upload_time_iso_8601": "2024-03-23T19:56:41.559504Z",
            "url": "https://files.pythonhosted.org/packages/67/11/b3928ec034cd639be86919ce1c58bff36bb59ee4add188b472aeac2dd59e/pytranscript-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0d167d4b00ed27877f1b1f29e17a1b7960ddae723dd115eab265fdb89dacee8d",
                "md5": "26d3f9fc3329bc3dcc54214f26948eb1",
                "sha256": "f21cbc8ed3a0c78f00a55d2568bbdb8083cd62e7910316da383b46df91d73510"
            },
            "downloads": -1,
            "filename": "pytranscript-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "26d3f9fc3329bc3dcc54214f26948eb1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 8568,
            "upload_time": "2024-03-23T19:56:43",
            "upload_time_iso_8601": "2024-03-23T19:56:43.227575Z",
            "url": "https://files.pythonhosted.org/packages/0d/16/7d4b00ed27877f1b1f29e17a1b7960ddae723dd115eab265fdb89dacee8d/pytranscript-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-23 19:56:43",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "arnaud-ma",
    "github_project": "pytranscript#readme",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pytranscript"
}
        
Elapsed time: 0.20654s