sampling audio doesn't preserve waves (vectors)!How do you remove duplicates from a list whilst preserving order?voice recording in Ogg format?Verizon SongID - How is it programmed?Audio Manipulation In C++Visualisation with PCM wave dataSaving audio input of Android Stock speech recognition enginePlaying multiple tracks of audio onlinePlaying 15 audio tracks at once with <50ms latency?Telegram Bot API answerInlineQuery sends voice files as documentsHow to get a .m4a audio file from a .opus audio file programmatically
The Sword in the Stone
If a 2019 UA artificer has the Repeating Shot infusion on two hand crossbows, can they use two-weapon fighting?
Is it possible to pass "draft" option to documentclass with arara?
Melee or Ranged attacks by Monsters, no distinction in modifiers?
How to tar a list of directories only if they exist
If my pay period is split between 2 calendar years, which tax year do I file them in?
How to write the derivative of a function as a limit (using first principles).
Is my employer paying me fairly? Going from 1099 to W2
How do campaign rallies gain candidates votes?
Correlation length anisotropy in the 2D Ising model
Please explain joy and/or the Kimatthiyasutta
Are the named pipe created by `mknod` and the FIFO created by `mkfifo` equivalent?
Aftermath of nuclear disaster at Three Mile Island
Why/when is AC-DC-AC conversion superior to direct AC-AC conversion?
Why is drive/partition number still used?
How to judge a Ph.D. applicant that arrives "out of thin air"
Does a Rogue's Evasion work for spells?
Is a topological space considered to be a class in set theory?
How do I stop my characters falling in love?
Polyhedra, Polyhedron, Polytopes and Polygon
Why force the nose of 737 Max down in the first place?
Why does Canada require mandatory bilingualism in all government posts?
Suggestions for protecting jeans from saddle clamp bolt
How do I handle academic references for US PhD program, when I have been out of academia for a (very) long time?
sampling audio doesn't preserve waves (vectors)!
How do you remove duplicates from a list whilst preserving order?voice recording in Ogg format?Verizon SongID - How is it programmed?Audio Manipulation In C++Visualisation with PCM wave dataSaving audio input of Android Stock speech recognition enginePlaying multiple tracks of audio onlinePlaying 15 audio tracks at once with <50ms latency?Telegram Bot API answerInlineQuery sends voice files as documentsHow to get a .m4a audio file from a .opus audio file programmatically
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I made a Telegram robot, and one of its jobs is to create samples from audio files. Now for most audios that is sent to it, the sample is perfectly fine; something like this:

However, for some audios, the sample looks a bit odd:

As you can see, the waves in this file are not shown! (I can assure you that the voice is not empty)
For creating the sample, I use pydub (Thanks, James!). Here's the part that I create the sample:
song = AudioSegment.from_mp3('song.mp3')
sliced = song[start*1000:end*1000]
sliced.export('song.ogg', format='ogg', parameters=["-acodec", "libopus"])
And then I send the sample using bot.send_voice method. Like this:
bot.send_voice(
chat_id=update.message.chat.id,
voice=open('song.ogg', 'rb'),
caption=settings.caption,
parse_mode=ParseMode.MARKDOWN,
timeout=1000
)
The documentation of Telegram Bot API says:
Use this method to send audio files, if you want Telegram clients to
display the file as a playable voice message. For this to work, your
audio must be in an .ogg file encoded with OPUS (other formats may be
sent as Audio or Document).
That's why in this line of code:
sliced.export('song.ogg', format='ogg', parameters=["-acodec", "libopus"])
I used parameters=["-acodec", "libopus"].
Can anyone tell me what I'm doing wrong? Thanks in advance!
python audio telegram python-telegram-bot pydub
add a comment |
I made a Telegram robot, and one of its jobs is to create samples from audio files. Now for most audios that is sent to it, the sample is perfectly fine; something like this:

However, for some audios, the sample looks a bit odd:

As you can see, the waves in this file are not shown! (I can assure you that the voice is not empty)
For creating the sample, I use pydub (Thanks, James!). Here's the part that I create the sample:
song = AudioSegment.from_mp3('song.mp3')
sliced = song[start*1000:end*1000]
sliced.export('song.ogg', format='ogg', parameters=["-acodec", "libopus"])
And then I send the sample using bot.send_voice method. Like this:
bot.send_voice(
chat_id=update.message.chat.id,
voice=open('song.ogg', 'rb'),
caption=settings.caption,
parse_mode=ParseMode.MARKDOWN,
timeout=1000
)
The documentation of Telegram Bot API says:
Use this method to send audio files, if you want Telegram clients to
display the file as a playable voice message. For this to work, your
audio must be in an .ogg file encoded with OPUS (other formats may be
sent as Audio or Document).
That's why in this line of code:
sliced.export('song.ogg', format='ogg', parameters=["-acodec", "libopus"])
I used parameters=["-acodec", "libopus"].
Can anyone tell me what I'm doing wrong? Thanks in advance!
python audio telegram python-telegram-bot pydub
add a comment |
I made a Telegram robot, and one of its jobs is to create samples from audio files. Now for most audios that is sent to it, the sample is perfectly fine; something like this:

However, for some audios, the sample looks a bit odd:

As you can see, the waves in this file are not shown! (I can assure you that the voice is not empty)
For creating the sample, I use pydub (Thanks, James!). Here's the part that I create the sample:
song = AudioSegment.from_mp3('song.mp3')
sliced = song[start*1000:end*1000]
sliced.export('song.ogg', format='ogg', parameters=["-acodec", "libopus"])
And then I send the sample using bot.send_voice method. Like this:
bot.send_voice(
chat_id=update.message.chat.id,
voice=open('song.ogg', 'rb'),
caption=settings.caption,
parse_mode=ParseMode.MARKDOWN,
timeout=1000
)
The documentation of Telegram Bot API says:
Use this method to send audio files, if you want Telegram clients to
display the file as a playable voice message. For this to work, your
audio must be in an .ogg file encoded with OPUS (other formats may be
sent as Audio or Document).
That's why in this line of code:
sliced.export('song.ogg', format='ogg', parameters=["-acodec", "libopus"])
I used parameters=["-acodec", "libopus"].
Can anyone tell me what I'm doing wrong? Thanks in advance!
python audio telegram python-telegram-bot pydub
I made a Telegram robot, and one of its jobs is to create samples from audio files. Now for most audios that is sent to it, the sample is perfectly fine; something like this:

However, for some audios, the sample looks a bit odd:

As you can see, the waves in this file are not shown! (I can assure you that the voice is not empty)
For creating the sample, I use pydub (Thanks, James!). Here's the part that I create the sample:
song = AudioSegment.from_mp3('song.mp3')
sliced = song[start*1000:end*1000]
sliced.export('song.ogg', format='ogg', parameters=["-acodec", "libopus"])
And then I send the sample using bot.send_voice method. Like this:
bot.send_voice(
chat_id=update.message.chat.id,
voice=open('song.ogg', 'rb'),
caption=settings.caption,
parse_mode=ParseMode.MARKDOWN,
timeout=1000
)
The documentation of Telegram Bot API says:
Use this method to send audio files, if you want Telegram clients to
display the file as a playable voice message. For this to work, your
audio must be in an .ogg file encoded with OPUS (other formats may be
sent as Audio or Document).
That's why in this line of code:
sliced.export('song.ogg', format='ogg', parameters=["-acodec", "libopus"])
I used parameters=["-acodec", "libopus"].
Can anyone tell me what I'm doing wrong? Thanks in advance!
python audio telegram python-telegram-bot pydub
python audio telegram python-telegram-bot pydub
edited Mar 28 at 12:52
deergadan
asked Mar 26 at 17:34
deergadandeergadan
1,1461 gold badge11 silver badges26 bronze badges
1,1461 gold badge11 silver badges26 bronze badges
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Shot in the dark guess:
Having just sampled those two Muse songs, "Pressure" is a much louder rock song than "The Void". I suspect Telegram service itself just detects the music as noise when performing speech to text translation. Unlike speech, which has an wide dynamic range between spoken words, music tends to be all the same volume. Hence, the relative volume of each sample is relatively the same - hence, a flat line.
add a comment |
Since it happen only to some of the songs, I believe the issues is linked with the original song format. Make sure that pudub got file parameters right, e.g.: number of channels, sample width, frame rate, etc. Sometimes the resulting format also changes, so you can get audio in range [-1..1] (float), and sometimes [-32767..32768] (integer).
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55363144%2fsampling-audio-doesnt-preserve-waves-vectors%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Shot in the dark guess:
Having just sampled those two Muse songs, "Pressure" is a much louder rock song than "The Void". I suspect Telegram service itself just detects the music as noise when performing speech to text translation. Unlike speech, which has an wide dynamic range between spoken words, music tends to be all the same volume. Hence, the relative volume of each sample is relatively the same - hence, a flat line.
add a comment |
Shot in the dark guess:
Having just sampled those two Muse songs, "Pressure" is a much louder rock song than "The Void". I suspect Telegram service itself just detects the music as noise when performing speech to text translation. Unlike speech, which has an wide dynamic range between spoken words, music tends to be all the same volume. Hence, the relative volume of each sample is relatively the same - hence, a flat line.
add a comment |
Shot in the dark guess:
Having just sampled those two Muse songs, "Pressure" is a much louder rock song than "The Void". I suspect Telegram service itself just detects the music as noise when performing speech to text translation. Unlike speech, which has an wide dynamic range between spoken words, music tends to be all the same volume. Hence, the relative volume of each sample is relatively the same - hence, a flat line.
Shot in the dark guess:
Having just sampled those two Muse songs, "Pressure" is a much louder rock song than "The Void". I suspect Telegram service itself just detects the music as noise when performing speech to text translation. Unlike speech, which has an wide dynamic range between spoken words, music tends to be all the same volume. Hence, the relative volume of each sample is relatively the same - hence, a flat line.
answered Mar 28 at 18:33
selbieselbie
59.4k11 gold badges69 silver badges131 bronze badges
59.4k11 gold badges69 silver badges131 bronze badges
add a comment |
add a comment |
Since it happen only to some of the songs, I believe the issues is linked with the original song format. Make sure that pudub got file parameters right, e.g.: number of channels, sample width, frame rate, etc. Sometimes the resulting format also changes, so you can get audio in range [-1..1] (float), and sometimes [-32767..32768] (integer).
add a comment |
Since it happen only to some of the songs, I believe the issues is linked with the original song format. Make sure that pudub got file parameters right, e.g.: number of channels, sample width, frame rate, etc. Sometimes the resulting format also changes, so you can get audio in range [-1..1] (float), and sometimes [-32767..32768] (integer).
add a comment |
Since it happen only to some of the songs, I believe the issues is linked with the original song format. Make sure that pudub got file parameters right, e.g.: number of channels, sample width, frame rate, etc. Sometimes the resulting format also changes, so you can get audio in range [-1..1] (float), and sometimes [-32767..32768] (integer).
Since it happen only to some of the songs, I believe the issues is linked with the original song format. Make sure that pudub got file parameters right, e.g.: number of channels, sample width, frame rate, etc. Sometimes the resulting format also changes, so you can get audio in range [-1..1] (float), and sometimes [-32767..32768] (integer).
answered Mar 31 at 6:27
igrinisigrinis
3,2314 silver badges18 bronze badges
3,2314 silver badges18 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55363144%2fsampling-audio-doesnt-preserve-waves-vectors%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown