소스 검색

update packages

subDesTagesMitExtraKaese 2 년 전
부모
커밋
d413f0e33f
4개의 변경된 파일39개의 추가작업 그리고 5개의 파일을 삭제
  1. 1 0
      .gitignore
  2. 34 0
      audio.py
  3. 4 5
      beleg.ipynb
  4. BIN
      beleg.pdf

+ 1 - 0
.gitignore

@@ -3,3 +3,4 @@
 .ipynb_checkpoints/
 
 .vscode/
+__pycache__/

+ 34 - 0
audio.py

@@ -0,0 +1,34 @@
+import IPython.display
+import numpy as np
+import json
+
+def Audio(audio: np.ndarray, rate: int):
+    """
+    Use instead of IPython.display.Audio as a workaround for VS Code.
+    `audio` is an array with shape (channels, samples) or just (samples,) for mono.
+    """
+
+    if np.ndim(audio) == 1:
+        channels = [audio.tolist()]
+    else:
+        channels = audio.tolist()
+
+    return IPython.display.HTML("""
+        <script>
+            if (!window.audioContext) {
+                window.audioContext = new AudioContext();
+                window.playAudio = function(audioChannels, sr) {
+                    const buffer = audioContext.createBuffer(audioChannels.length, audioChannels[0].length, sr);
+                    for (let [channel, data] of audioChannels.entries()) {
+                        buffer.copyToChannel(Float32Array.from(data), channel);
+                    }
+            
+                    const source = audioContext.createBufferSource();
+                    source.buffer = buffer;
+                    source.connect(audioContext.destination);
+                    source.start();
+                }
+            }
+        </script>
+        <button onclick="playAudio(%s, %s)" style="padding: 10px">Play</button>
+    """ % (json.dumps(channels), rate))

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 4 - 5
beleg.ipynb


BIN
beleg.pdf


이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.