test "Converts sample audio to text" do
current_dir = __DIR__
file_path = Path.join([current_dir, "../../fixtures/test.wav"])
absolute_path = Path.expand(file_path)
sample_audio = File.read!(absolute_path)
expected_text =
"Adventure 1 a scandal in Bohemia from The Adventures of Sherlock Holmes by Sir Arthur Conan Doyle. This is a LibriVox recording."
links = [
child(:source, %Source{output: [sample_audio], stream_format: %RawAudio{sample_format: :s16le, sample_rate: 16_000, channels: 1}})
|> child(:speech_2_text, Speech2Text)
|> child(:sink, %Sink{})
]
options = [
spec: links
]
pipeline = Pipeline.start_link_supervised!(options)
assert_sink_buffer(pipeline, :sink, {:buffer, %Buffer{payload: ^expected_text}}, 5_000)
Pipeline.terminate(pipeline)
end
test "Converts sample audio to text" do
current_dir = __DIR__
file_path = Path.join([current_dir, "../../fixtures/test.wav"])
absolute_path = Path.expand(file_path)
sample_audio = File.read!(absolute_path)
expected_text =
"Adventure 1 a scandal in Bohemia from The Adventures of Sherlock Holmes by Sir Arthur Conan Doyle. This is a LibriVox recording."
links = [
child(:source, %Source{output: [sample_audio], stream_format: %RawAudio{sample_format: :s16le, sample_rate: 16_000, channels: 1}})
|> child(:speech_2_text, Speech2Text)
|> child(:sink, %Sink{})
]
options = [
spec: links
]
pipeline = Pipeline.start_link_supervised!(options)
assert_sink_buffer(pipeline, :sink, {:buffer, %Buffer{payload: ^expected_text}}, 5_000)
Pipeline.terminate(pipeline)
end