|
| 1 | +--- |
| 2 | +title: "ArtBox: What is it and how to collaborate?" |
| 3 | +slug: artbox-what-is-it-how-to-collaborete |
| 4 | +date: 2024-04-02 |
| 5 | +authors: ["Daniela Iglesias Rocabado"] |
| 6 | +tags: [open-source, art, python, multimedia processing] |
| 7 | +categories: [python] |
| 8 | +description: | |
| 9 | + ArtBox is a tool set for handling multimedia files with a bunch of useful functions. |
| 10 | +thumbnail: "/header.jpg" |
| 11 | +template: "blog-post.html" |
| 12 | +--- |
| 13 | +# How to use it? |
| 14 | + |
| 15 | +## What is ArtBox? |
| 16 | + |
| 17 | +ArtBox is a versatile tool set designed for efficient multimedia file handling, offering a range of valuable functions to enhance your multimedia processing experience. |
| 18 | + |
| 19 | + |
| 20 | +Key features of ArtBox include capabilities for text-to-audio conversion, YouTube video downloading, musical composition from notes, audio removal from video clips, audio extraction, and merging audio with video files. These functionalities position ArtBox as a pivotal tool for multimedia enthusiasts, content creators, and anyone in need of efficient multimedia processing solutions. |
| 21 | + |
| 22 | + |
| 23 | +### Installation |
| 24 | + |
| 25 | +ArtBox relies on certain dependencies that may not function optimally on your machine. To ensure a smooth installation process, it is recommended to create a conda/mamba environment and install ArtBox within that environment. |
| 26 | + |
| 27 | +```bash |
| 28 | +$ mamba create --name artbox "python>=3.8.1,<3.12" pygobject pip |
| 29 | +``` |
| 30 | + |
| 31 | +The command is creating a conda environment named "artbox" with Python version 3.8.1 or later, and includes the pygobject and pip packages in the environment. This is useful for setting up an isolated environment for a specific project or application, ensuring compatibility and reproducibility of the software stack. |
| 32 | + |
| 33 | +```bash |
| 34 | +$ conda activate artbox |
| 35 | +``` |
| 36 | + |
| 37 | +To prevent dependency conflicts, please install the numpy library using the following command: |
| 38 | + |
| 39 | +```bash |
| 40 | +$ pip install "numpy>=1.20" |
| 41 | +``` |
| 42 | + |
| 43 | +The `conda activate artbox` command is used to activate the "artbox" conda environment, ensuring that subsequent commands or scripts run within this isolated environment. Activation modifies the system's `PATH` to prioritize the "artbox" environment, allowing for the use of specific Python versions and packages associated with the project, thus maintaining a clean and reproducible development or execution environment. |
| 44 | + |
| 45 | + |
| 46 | +```python |
| 47 | +$ !mamba install -q -y -c conda-forge pygobject pip |
| 48 | +``` |
| 49 | + |
| 50 | + |
| 51 | +```python |
| 52 | +$ !pip install -q artbox |
| 53 | +``` |
| 54 | + |
| 55 | +The `pip install artbox` command is used to install the Python package named "artbox" using the pip package manager. This command fetches the "artbox" package from the Python Package Index (PyPI) and installs it into the currently active Python environment. The `pip install` command is commonly used to add external packages or libraries to a Python environment, expanding its functionality for a particular project or application. |
| 56 | + |
| 57 | +## Examples of Artbox usage. |
| 58 | +For the following examples, create the a temporary folder for artbox: |
| 59 | + |
| 60 | + |
| 61 | +```python |
| 62 | +$ mkdir /tmp/artbox |
| 63 | +``` |
| 64 | + |
| 65 | +### Convert text to audio |
| 66 | + |
| 67 | +By default, the `artbox voice` uses |
| 68 | +[`edge-tts`](https://pypi.org/project/edge-tts/) engine, but you can also |
| 69 | +specify [`gtts`](https://github.com/pndurette/gTTS) with the flag |
| 70 | +`--engine gtts`. |
| 71 | + |
| 72 | + |
| 73 | +```python |
| 74 | +$ echo "Are you ready to join Link and Zelda in fighting off this unprecedented threat to Hyrule?" > /tmp/artbox/text.md |
| 75 | +$ artbox speech from-text \ |
| 76 | + --title artbox \ |
| 77 | + --input-path /tmp/artbox/text.md \ |
| 78 | + --output-path /tmp/artbox/speech.mp3 \ |
| 79 | + --engine edge-tts |
| 80 | +``` |
| 81 | + |
| 82 | +If you need to generate the audio for different language, you can use the flag |
| 83 | +`--lang`: |
| 84 | + |
| 85 | + |
| 86 | +```python |
| 87 | +$ echo "Bom dia, mundo!" > /tmp/artbox/text.md |
| 88 | +$ artbox speech from-text \ |
| 89 | + --title artbox \ |
| 90 | + --input-path /tmp/artbox/text.md \ |
| 91 | + --output-path /tmp/artbox/speech.mp3 \ |
| 92 | + --lang pt |
| 93 | +``` |
| 94 | + |
| 95 | +If you are using `edge-tts` engine (the default one), you can also specify the |
| 96 | +locale for the language, for example: |
| 97 | + |
| 98 | + |
| 99 | +```python |
| 100 | +$ echo "Are you ready to join Link and Zelda in fighting off this unprecedented threat to Hyrule?" > /tmp/artbox/text.md |
| 101 | +$ artbox speech from-text \ |
| 102 | + --title artbox \ |
| 103 | + --input-path /tmp/artbox/text.md \ |
| 104 | + --output-path /tmp/artbox/speech.mp3 \ |
| 105 | + --engine edge-tts \ |
| 106 | + --lang en-IN |
| 107 | +``` |
| 108 | + |
| 109 | +Additionally, if you are using edge-tts, you can specify `--rate`, `--volume`, and `--pitch`, for example: |
| 110 | + |
| 111 | + |
| 112 | +```python |
| 113 | +$ echo "Do you want some coffee?" > /tmp/artbox/text.md |
| 114 | +$ artbox speech from-text \ |
| 115 | + --title artbox \ |
| 116 | + --input-path /tmp/artbox/text.md \ |
| 117 | + --output-path /tmp/artbox/speech.mp3 \ |
| 118 | + --engine edge-tts \ |
| 119 | + --lang en \ |
| 120 | + --rate +10% \ |
| 121 | + --volume -10% \ |
| 122 | + --pitch -5Hz |
| 123 | +``` |
| 124 | + |
| 125 | +### Convert audio to text |
| 126 | +ArtBox uses `speechrecognition` to convert from audio to text. Currently, ArtBox just support the google engine. |
| 127 | + |
| 128 | +For this example, let's first create our audio: |
| 129 | + |
| 130 | + |
| 131 | +```python |
| 132 | +$ echo "Are you ready to join Link and Zelda in fighting off this unprecedented threat to Hyrule?" > /tmp/artbox/text.md |
| 133 | +$ artbox speech from-text \ |
| 134 | + --title artbox \ |
| 135 | + --input-path /tmp/artbox/text.md \ |
| 136 | + --output-path /tmp/artbox/speech.mp3 \ |
| 137 | + --engine edge-tts |
| 138 | +``` |
| 139 | + |
| 140 | +Now we can convert it back to text: |
| 141 | + |
| 142 | + |
| 143 | +```python |
| 144 | +$ artbox speech to-text \ |
| 145 | + --input-path /tmp/artbox/speech.mp3 \ |
| 146 | + --output-path /tmp/artbox/text-from-speech.md \ |
| 147 | + --lang en |
| 148 | +``` |
| 149 | + |
| 150 | +### Download a youtube video |
| 151 | + |
| 152 | +If you want to download videos from the youtube, you can use the following |
| 153 | +command: |
| 154 | + |
| 155 | + |
| 156 | +```python |
| 157 | +$ artbox youtube download \ |
| 158 | + --url https://www.youtube.com/watch?v=zw47_q9wbBE \ |
| 159 | + --output-path /tmp/artbox/ |
| 160 | +``` |
| 161 | + |
| 162 | +The command above downloads the video using a random resolution. If you want a specific resolution, use the flat `--resolution`: |
| 163 | + |
| 164 | + |
| 165 | +```python |
| 166 | +$ artbox youtube download \ |
| 167 | + --url https://www.youtube.com/watch?v=zw47_q9wbBE \ |
| 168 | + --output-path /tmp/artbox/ \ |
| 169 | + --resolution 360p |
| 170 | +``` |
| 171 | + |
| 172 | +### Remove the audio from a video |
| 173 | + |
| 174 | +First, download the youtube video `https://www.youtube.com/watch?v=zw47_q9wbBE`, as explained before. |
| 175 | + |
| 176 | +Next, run the following command: |
| 177 | + |
| 178 | + |
| 179 | +```python |
| 180 | +$ artbox video remove-audio \ |
| 181 | + --input-path "/tmp/artbox/The Legend of Zelda Breath of the Wild - Nintendo Switch Presentation 2017 Trailer.mp4" \ |
| 182 | + --output-path /tmp/artbox/botw.mp4 |
| 183 | +``` |
| 184 | + |
| 185 | +### Extract the audio from a video |
| 186 | + |
| 187 | +First, download the youtube video `https://www.youtube.com/watch?v=zw47_q9wbBE`, |
| 188 | +as explained before. |
| 189 | + |
| 190 | +Next, run the following command: |
| 191 | + |
| 192 | + |
| 193 | +```python |
| 194 | +$ artbox video extract-audio \ |
| 195 | + --input-path "/tmp/artbox/The Legend of Zelda Breath of the Wild - Nintendo Switch Presentation 2017 Trailer.mp4" \ |
| 196 | + --output-path /tmp/artbox/botw-audio.mp3 |
| 197 | +``` |
| 198 | + |
| 199 | +### Combine audio and video files |
| 200 | + |
| 201 | +First, execute the previous steps: |
| 202 | + |
| 203 | +- Download a youtube video |
| 204 | +- Remove the audio from a video |
| 205 | +- Extract the audio from a video |
| 206 | + |
| 207 | +Next, run the following command: |
| 208 | + |
| 209 | + |
| 210 | +```python |
| 211 | +$ artbox video combine-video-and-audio \ |
| 212 | + --video-path /tmp/artbox/botw.mp4 \ |
| 213 | + --audio-path /tmp/artbox/botw-audio.mp3 \ |
| 214 | + --output-path /tmp/artbox/botw-combined.mp4 |
| 215 | +``` |
| 216 | + |
| 217 | +## Additional dependencies |
| 218 | + |
| 219 | +If you want to use Python to play your audio files, you can install `playsound`: |
| 220 | + |
| 221 | + |
| 222 | +```python |
| 223 | +$ pip wheel --use-pep517 "playsound (==1.3.0)" |
| 224 | +``` |
| 225 | + |
| 226 | +### Demo Video |
| 227 | + |
| 228 | +For a better explanation of the facilities and usage, please watch to the following video. |
| 229 | + |
| 230 | +<iframe width="560" height="315" src="https://www.youtube.com/embed/sITnMuZTNAw?si=goPrd2BhPxy7Fqku" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe> |
0 commit comments