mirror of
https://github.com/macaodha/batdetect2.git
synced 2025-06-29 22:51:58 +02:00
Fix error in get_samplerate when reading io.BytesIO.
This commit is contained in:
parent
6af7fef316
commit
e10e270de4
@ -9,6 +9,7 @@ import torch
|
|||||||
import audioread
|
import audioread
|
||||||
import os
|
import os
|
||||||
import soundfile as sf
|
import soundfile as sf
|
||||||
|
import io
|
||||||
|
|
||||||
from batdetect2.detector import parameters
|
from batdetect2.detector import parameters
|
||||||
|
|
||||||
@ -147,7 +148,10 @@ def generate_spectrogram(
|
|||||||
def get_samplerate(
|
def get_samplerate(
|
||||||
path: Union[
|
path: Union[
|
||||||
str, int, os.PathLike[Any], sf.SoundFile, audioread.AudioFile, BinaryIO
|
str, int, os.PathLike[Any], sf.SoundFile, audioread.AudioFile, BinaryIO
|
||||||
]):
|
]):
|
||||||
|
if isinstance(path, (BinaryIO, io.BytesIO)):
|
||||||
|
path.seek(0)
|
||||||
|
|
||||||
with sf.SoundFile(path) as f:
|
with sf.SoundFile(path) as f:
|
||||||
return f.samplerate
|
return f.samplerate
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user