Last active
March 12, 2022 12:31
-
-
Save mouseos/c66154199c2b118809a40dd36644a9de to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import wave | |
| import time | |
| #ffmpeg -i test.ogg -vn -ar 44100 -ac 2 test.wavしておく | |
| #ffplay output -ar 44.1k -ac 2 -f s16leで再生 | |
| #ffmpeg -ar 44.1k -ac 2 -f s16le -i output out.wavで録音 | |
| wf = wave.open('test.wav', mode='rb') | |
| #事前にmkfifo outputしておく | |
| owf= open('output', 'w+b', 0) | |
| frames=int(wf.getnframes()) | |
| for i in range(int(frames/8)): | |
| data=(wf.readframes(8) ) | |
| print(data) | |
| owf.write(data) | |
| time.sleep(1/44100) | |
| while True:#音声がない場合に無音を書き込む処理 | |
| owf.write(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') | |
| time.sleep(1/44100) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.