Skip to content
Snippets Groups Projects
Verified Commit 2142f5d1 authored by Lucas Ondel Yang's avatar Lucas Ondel Yang
Browse files

load from audio source

parent fe26b226
No related branches found
No related tags found
No related merge requests found
# Tags
## [0.5.0](https://https://gitlab.lisn.upsaclay.fr/fast/speechcorpora.jl/-/tags/v0.5.0)- 25/09/2023
## Added
- can load the data directly from an audio source with the `load`
function.
## [0.4.1](https://https://gitlab.lisn.upsaclay.fr/fast/speechcorpora.jl/-/tags/v0.4.1)- 25/09/2023
## Added
* HTML display of AudioSource rather than recording
......
name = "SpeechCorpora"
uuid = "3225a15e-d855-4a07-9546-2418058331ae"
authors = ["Lucas ONDEL YANG <lucas.ondel@cnrs.fr>"]
version = "0.4.1"
version = "0.5.0"
[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
......
......@@ -7,7 +7,7 @@ function Base.show(io::IO, ::MIME"text/html", r::AbstractAudioSource)
print(io, "<audio controls ")
print(io, "src=\"data:audio/wav;base64,")
x, s, _ = loadsource(r, :)
x, s = load(r)
iob64_encode = Base64EncodePipe(io)
wavwrite(x, iob64_encode, Fs = s, nbits = 8, compression = WAV.WAVE_FORMAT_PCM)
close(iob64_encode)
......
......@@ -8,9 +8,9 @@ Base class for all audio source. Possible audio sources are:
* `URLAudioSource`
* `CmdAudioSource`
You can load the data of an audio source with the internal function
You can load the data of an audio source with the function
loadsoce(s::AbstractAudioSource, subrange)
load(s::AbstractAudioSource, subrange = :)
"""
abstract type AbstractAudioSource end
......@@ -28,9 +28,9 @@ struct CmdAudioSource <: AbstractAudioSource
end
CmdAudioSource(c::String) = CmdAudioSource(Cmd(String.(split(c))))
loadsource(s::FileAudioSource, subrange) = wavread(s.path; subrange)
loadsource(s::URLAudioSource, subrange) = wavread(IOBuffer(HTTP.get(s.url).body); subrange)
loadsource(s::CmdAudioSource, subrange) = wavread(IOBuffer(read(pipeline(s.cmd))); subrange)
load(s::FileAudioSource, subrange = :) = wavread(s.path; subrange)[1:2]
load(s::URLAudioSource, subrange = :) = wavread(IOBuffer(HTTP.get(s.url).body); subrange)[1:2]
load(s::CmdAudioSource, subrange = :) = wavread(IOBuffer(read(pipeline(s.cmd))); subrange)[1:2]
"""
abstract type ManifestItem end
......@@ -71,7 +71,7 @@ end
function Recording(uttid, s::AbstractAudioSource; channels = missing, samplerate = missing)
if ismissing(channels) || ismissing(samplerate)
x, sr = loadsource(s, :)
x, sr = load(s)
samplerate = ismissing(samplerate) ? Int(sr) : samplerate
channels = ismissing(channels) ? collect(1:size(x,2)) : channels
end
......@@ -134,7 +134,7 @@ function load(r::Recording; start = -1, duration = -1, channels = r.channels)
subrange = (:)
end
x, sr, _, _ = loadsource(r.source, subrange)
x, sr = load(r.source, subrange)
x[:,channels], sr
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment