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;








7















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:



enter image description here



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



enter image description here



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!










share|improve this question






























    7















    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:



    enter image description here



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



    enter image description here



    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!










    share|improve this question


























      7












      7








      7








      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:



      enter image description here



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



      enter image description here



      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!










      share|improve this question
















      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:



      enter image description here



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



      enter image description here



      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      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






















          2 Answers
          2






          active

          oldest

          votes


















          0














          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.






          share|improve this answer






























            0














            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).






            share|improve this answer

























              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
              );



              );













              draft saved

              draft discarded


















              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









              0














              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.






              share|improve this answer



























                0














                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.






                share|improve this answer

























                  0












                  0








                  0







                  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.






                  share|improve this answer













                  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.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 28 at 18:33









                  selbieselbie

                  59.4k11 gold badges69 silver badges131 bronze badges




                  59.4k11 gold badges69 silver badges131 bronze badges























                      0














                      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).






                      share|improve this answer



























                        0














                        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).






                        share|improve this answer

























                          0












                          0








                          0







                          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).






                          share|improve this answer













                          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).







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Mar 31 at 6:27









                          igrinisigrinis

                          3,2314 silver badges18 bronze badges




                          3,2314 silver badges18 bronze badges



























                              draft saved

                              draft discarded
















































                              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.




                              draft saved


                              draft discarded














                              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





















































                              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







                              Popular posts from this blog

                              SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                              용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

                              155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해