Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change style to specstyle; update docs #34

Merged
merged 1 commit into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/src/phon_spectrogram.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@ s = vec(s)
phonspec(s, fs)
```

A color scheme more similar to the Praat grayscale can be achieved using the `col` argument and the `:gist_yarg` color scheme. These spectrograms are created using the `heatmap` function from `Plots.jl`, so [any color scheme available in the Plots package](https://docs.juliaplots.org/stable/generated/colorschemes/) can be used, though not all of them produce legible spectrograms.
A color scheme more similar to the Praat grayscale can be achieved using the `color` argument from `Plots.jl` and the `:binary` color scheme. These spectrograms are created using the `heatmap` function from `Plots.jl`, so [any color scheme available in the Plots package](https://docs.juliaplots.org/stable/generated/colorschemes/) can be used, though not all of them produce legible spectrograms.

```@example
using Phonetics # hide
using WAV # hide
s, fs = wavread("assets/iwantaspectrogram.wav") # hide
s = vec(s) # hide
using Plots # hide
phonspec(s, fs, col=:binary)
phonspec(s, fs, color=:binary)
```

A narrowband style spectrogram can be plotted using the `style` argument:
A narrowband style spectrogram can be plotted using the `specstyle` argument:

```@example
using Phonetics # hide
using WAV # hide
s, fs = wavread("assets/iwantaspectrogram.wav") # hide
s = vec(s) # hide
using Plots # hide
phonspec(s, fs, style=:narrowband)
phonspec(s, fs, specstyle=:narrowband)
```

And, the pre-emphasis can be disabled by passing in a value of 0 for the `pre_emph` argument. Pre-emphasis will boost the prevalence of the higher frequencies in comparison to the lower frequencies.
Expand Down
6 changes: 3 additions & 3 deletions src/phon_spectrogram.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
phonspec

@userplot PhonSpec
@recipe function f(p::PhonSpec; pre_emph=0.97, style=:broadband, dbr=55)
@recipe function f(p::PhonSpec; pre_emph=0.97, specstyle=:broadband, dbr=55)

Check warning on line 29 in src/phon_spectrogram.jl

View check run for this annotation

Codecov / codecov/patch

src/phon_spectrogram.jl#L29

Added line #L29 was not covered by tests

if length(p.args) != 2
error("Must pass 2 arguments for spectrogram, `s` the samples and `fs` the sampling frequency")
Expand All @@ -35,9 +35,9 @@

pre_emph_filt = PolynomialRatio([1, -pre_emph], [1])
s = filt(pre_emph_filt, s)
if style == :broadband
if specstyle == :broadband

Check warning on line 38 in src/phon_spectrogram.jl

View check run for this annotation

Codecov / codecov/patch

src/phon_spectrogram.jl#L38

Added line #L38 was not covered by tests
winlen = 0.005
elseif style == :narrowband
elseif specstyle == :narrowband

Check warning on line 40 in src/phon_spectrogram.jl

View check run for this annotation

Codecov / codecov/patch

src/phon_spectrogram.jl#L40

Added line #L40 was not covered by tests
winlen = 0.05
else
error("Unsupported `style` value. Value must be either `:broadband` or `:narrowband`")
Expand Down
Loading