vishal-h
Audio streaming gives an error while using Elixir Req
There’s a python/fastapi service that streams audio files. I don’t have access to the code of this service.
This works fine and the audio can be played.
<audio controls src="some/audio/url">
Your browser does not support the <code>audio</code> element.
</audio>
This one doesn’t
Mix.install([
{:req, "~> 0.4.0"}
])
url = "some/audio/url"
Req.get!(url, into: IO.stream())
|> Stream.each(&IO.inspect/1)
|> Stream.run()
The following error is thrown
** (ArgumentError) errors were found at the given arguments:
* 2nd argument: not valid character data (an iodata term)
(stdlib 4.0.1) io.erl:99: :io.put_chars(:standard_io, <<0, 0, 0, 24, 102, ...>>)
(req 0.4.5) lib/req/steps.ex:760: anonymous fn/3 in Req.Steps.finch_stream_into_collectable/5
(finch 0.16.0) lib/finch/http1/conn.ex:231: Finch.Conn.receive_response/8
(finch 0.16.0) lib/finch/http1/conn.ex:120: Finch.Conn.request/6
(finch 0.16.0) lib/finch/http1/pool.ex:45: anonymous fn/8 in Finch.HTTP1.Pool.request/5
(nimble_pool 1.0.0) lib/nimble_pool.ex:349: NimblePool.checkout!/4
(finch 0.16.0) lib/finch/http1/pool.ex:38: Finch.HTTP1.Pool.request/5
What am I missing?
Marked As Solved
al2o3cr
By default, IO.stream is expecting to read and write UTF8-shaped byte sequences.
Raw audio data is definitely not that.
You likely want IO.binstream, though connecting that to an already-open stdio may need additional code.
2
Popular in Questions
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
Credo is smart enough to check for (something like) this:
assert length(the_list) == 0
with this response:
Checking if an enum is empt...
New
This should be a simple problem but I just can’t seem to figure it out. I have a standalone Elixir app that won’t find the database.
Dep...
New
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
Hey guys.
I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this
"1000"
What is the ...
New
Hi guys, nice to meet you to the whole forum, I’m new here, I’m trying to configure visual studio code for elixir, right now the intellis...
New
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Sometimes I want to check if the input into a function is not a blank string.
My first approach:
defmodule Example do
def do_stuff(s...
New
Hi everyone!
I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
Other popular topics
Hello!
tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability.
After spen...
New
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
Hello all!
I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
I have an umbrella app.
Some of the apps inside depend on other apps in the umbrella, unsurprisingly.
I'm writing a test for one of t...
New
Hi,
I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible.
total = 10
while total != 0
...
New
Hello, I have map which I want to convert it to string like this:
the map:
%{last_name: "tavakkoli", name: "shahryar"}
the string I ne...
New
Hello guys,
I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New







