Skip to content

Commit

Permalink
Update plot grupo documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
dunossauro committed Aug 31, 2023
1 parent b4233f0 commit 9b8e666
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 35 deletions.
131 changes: 101 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -447,39 +447,110 @@ Usage: vmh grammar-check [OPTIONS] FILE [LANG]

3. **Regular Audits**: For long projects with vast subtitle files, consider periodic grammar checks. This will not only help maintain the quality of your content but also ensure that any corrections can be integrated without revisiting large portions of your work.

### All options
### Plot commands

TODO doc
Plotting commands offer tools to visualize audio files, facilitating debugging and comprehension of audio processing. Here's how to use them:

```
vmh plot
Usage: vmh plot [OPTIONS] COMMAND [ARGS]...
Audio debug tools.
╭─ Options ───────────────────────────────────────────────────────────────────────────────╮
│ --help Show this message and exit. │
╰─────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ──────────────────────────────────────────────────────────────────────────────╮
│ compare-waves Plot a figure with N audio waves for comparison. │
│ plot-wave Plot a figure with audio wave. │
╰─────────────────────────────────────────────────────────────────────────────────────────╯
```

#### `plot-wave`

Visualize a single audio waveform to better understand its characteristics.

##### `--help`

```
vmh plot plot-wave --help
Usage: vmh plot plot-wave [OPTIONS] FILE FIG_NAME
Plot a figure with audio wave.
╭─ Arguments ─────────────────────────────────────────────────────────╮
│ * file TEXT [default: None] [required] │
│ * fig_name TEXT [default: None] [required] │
╰─────────────────────────────────────────────────────────────────────╯
╭─ Options ───────────────────────────────────────────────────────────╮
│ --help Show this message and exit. │
╰─────────────────────────────────────────────────────────────────────╯
```

#### `compare-waves`

Create a comparative plot of multiple audio waves. Useful for comparing the effects of different audio processing steps or algorithms.

##### `--help`

```
vmh
Usage: vmh [OPTIONS] COMMAND [ARGS]...
Videomaker Helper!
╭─ Options ─────────────────────────────────────────────────────────────────────────────────────────────╮
│ --version -v Show VMH version │
│ --install-completion [bash|zsh|fish|powershell|pwsh] Install completion for the specified │
│ shell. │
│ [default: None] │
│ --show-completion [bash|zsh|fish|powershell|pwsh] Show completion for the specified │
│ shell, to copy it or customize the │
│ installation. │
│ [default: None] │
│ --help Show this message and exit. │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ────────────────────────────────────────────────────────────────────────────────────────────╮
│ cache Cache tools. │
│ cut-silences Removes all silences from an audio file. │
│ cut-video Edits a video using silences as reference. │
│ equalize Add Compression and Gain dor audio file. │
│ extract-audio Extracts the audio from a video. │
│ grammar-check Check grammar in a tex tfile. │
│ kdenlive Generates an XML compatible with kdenlive settings. │
│ silences Checks for silences in a audio file. │
│ transcribe Transcribes an audio file into subtitles. │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────╯
vmh plot compare-waves --help
Usage: vmh plot compare-waves [OPTIONS] FILES... FIG_NAME [FORCE_DB]
Plot a figure with N audio waves for comparison.
╭─ Arguments ───────────────────────────────────────────────────────────────────────╮
│ * files FILES... [default: None] [required] │
│ * fig_name TEXT [default: None] [required] │
│ force_db [FORCE_DB] Force to use 1 to -1 dbs in plot [default: True] │
╰───────────────────────────────────────────────────────────────────────────────────╯
╭─ Options ─────────────────────────────────────────────────────────────────────────╮
│ --fig-size <FLOAT FLOAT>... [default: 10, 12] │
│ --help Show this message and exit. │
╰───────────────────────────────────────────────────────────────────────────────────╯
```

### All options

Below are all the available options and commands for Videomaker Helper (VMH):

To get more details for each command, use vmh `<command> --help`.

This condensed guide can serve as a quick reference for anyone using your tool, making it easier to understand at a glance all the capabilities it offers.

```
vmh --help
Usage: vmh [OPTIONS] COMMAND [ARGS]...
Videomaker Helper!
╭─ Options ──────────────────────────────────────────────────────────────────────────────────────────────╮
│ --version -v Show VMH version │
│ --install-completion [bash|zsh|fish|powershell|pwsh] Install completion for the specified │
│ shell. │
│ [default: None] │
│ --show-completion [bash|zsh|fish|powershell|pwsh] Show completion for the specified │
│ shell, to copy it or customize the │
│ installation. │
│ [default: None] │
│ --help Show this message and exit. │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ─────────────────────────────────────────────────────────────────────────────────────────────╮
│ cache Cache tools. │
│ cut-silences Removes all silences from an audio file. │
│ cut-video Edits a video using silences as reference. │
│ equalize Add effects for audio file. │
│ extract-audio Extracts the audio from a video. │
│ grammar-check Check grammar in a tex tfile. │
│ kdenlive Generates an XML compatible with kdenlive settings. │
│ plot Audio debug tools. │
│ silences Checks for silences in a audio file. │
│ transcribe Transcribes an audio file into subtitles. │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────╯
```

## Distance Flag
Expand Down
9 changes: 4 additions & 5 deletions vmh/cli.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import warnings
from pathlib import Path
from shutil import rmtree
from typing import Annotated

from loguru import logger
from rich.console import Console
from typer import Argument, Context, Exit, Option, Typer

from vmh import audio, cache, video
from vmh import audio, cache, plot, video
from vmh.equalize import process_audio
from vmh.kdenlive import cut
from vmh.settings import __version__
Expand All @@ -19,6 +18,7 @@

app = Typer(help='Videomaker Helper!', no_args_is_help=True)
app.add_typer(cache.cache, name='cache', help='Cache tools.')
app.add_typer(plot.plot, name='plot', help='Audio debug tools.')


# Options
Expand Down Expand Up @@ -125,10 +125,9 @@ def cut_silences(
def equalize(
audio_file: path_arg,
output_file: Path = Argument(default='output.wav'),
gain: int = Option(10, '--gain', '-g', help='Add dbs in audio'),
):
"""Add Compression and Gain dor audio file."""
process_audio(str(audio_file.resolve()), str(output_file), gain)
"""Add effects for audio file."""
process_audio(str(audio_file.resolve()), str(output_file))

console.print(f'{output_file} Created')

Expand Down
38 changes: 38 additions & 0 deletions vmh/plot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import matplotlib.pyplot as plt
from librosa import load
from librosa.display import waveshow
from typer import Typer, Argument

plot = Typer(no_args_is_help=True)


@plot.command()
def plot_wave(file: str, fig_name: str) -> None:
"""Plot a figure with audio wave."""
y, sr = load(file, mono=False)
waveshow(y, sr=sr)

plt.savefig(fig_name)


@plot.command()
def compare_waves(
files: list[str],
fig_name: str,
fig_size: tuple[float, float] = (10, 12),
force_db: bool = Argument(True, help='Force to use 1 to -1 dbs in plot'),
) -> None:
"""Plot a figure with N audio waves for comparison."""
_, ax = plt.subplots(
nrows=len(files), sharex=True, figsize=fig_size, tight_layout=True
)

for n, file in enumerate(files):
if force_db:
ax[n].set(ylim=[-1.1, 1.1], title=file)
else:
ax[n].set(title=file)
y_b, sr_b = load(file, mono=False)
waveshow(y_b, sr=sr_b, ax=ax[n])

plt.savefig(fig_name)

0 comments on commit 9b8e666

Please sign in to comment.