HE_music_extractor.py
def write_pcm_to_mp3(
            output_path: Path,
            payload: bytes,
            samplerate: int,
            quality_or_bitrate: Union[int, str] = 0,
            title: str = None,
            artist: str = None,
            album: str = None,
            year: str = None,
            track: int = None,
            comment: str = None
    ):
        """
        Write unsigned 8-bit audio data to an MP3 file.

        :param output_path: path to write MP3 file
        :param payload: raw PCM samples
        :param samplerate: samplerate of the audio data
        :param quality_or_bitrate: if an integer, encode with this VBR quality
            preset, otherwise if a string (like '320k'), encode with CBR
        :param title: track name
        :param artist: track artist
        :param album: album name
        :param year: year created
        :param track: track number in album
        :param comment: comment string
        """

        options = ['-c:a', 'libmp3lame']

        if not (
                quality_or_bitrate is None
                or isinstance(quality_or_bitrate, (int, str))
        ):
            raise TypeError(
                f"quality_or_bitrate must one of type (int, str) or None, got "
                f"{type(quality_or_bitrate)}"
            )
        if isinstance(quality_or_bitrate, int):
            options += ['-q:a', str(quality_or_bitrate)]
        elif isinstance(quality_or_bitrate, str):
            options += ['-b:a', quality_or_bitrate]

        options += ['-metadata', f'title={title}'] if title else []
        options += ['-metadata', f'artist={artist}'] if artist else []
        options += ['-metadata', f'album={album}'] if album else []
        options += ['-metadata', f'date={year}'] if year else []
        options += ['-metadata', f'track={track}'] if track else []
        options += ['-metadata', f'comment={comment}'] if comment else []
        return write_pcm_to_file(output_path, payload, samplerate, options)

        Write unsigned 8-bit audio data to an MP3 file.

        :param output_path: path to write MP3 file
        :param payload: raw PCM samples
        :param samplerate: samplerate of the audio data
        :param quality_or_bitrate: if an integer, encode with this VBR quality
            preset, otherwise if a string (like '320k'), encode with CBR
        :param title: track name
        :param artist: track artist
        :param album: album name
        :param year: year created
        :param track: track number in album
        :param comment: comment string
        
Write unsigned 8-bit audio data to an MP3 file.
Write unsigned 8 - bit audio data to an MP3 file .
def write_pcm_to_mp3(
            output_path: Path,
            payload: bytes,
            samplerate: int,
            quality_or_bitrate: Union[int, str] = 0,
            title: str = None,
            artist: str = None,
            album: str = None,
            year: str = None,
            track: int = None,
            comment: str = None
    ):
        options = ['-c:a', 'libmp3lame']
        if not (
                quality_or_bitrate is None
                or isinstance(quality_or_bitrate, (int, str))
        ):
            raise TypeError(
                f"quality_or_bitrate must one of type (int, str) or None, got "
                f"{type(quality_or_bitrate)}"
            )
        if isinstance(quality_or_bitrate, int):
            options += ['-q:a', str(quality_or_bitrate)]
        elif isinstance(quality_or_bitrate, str):
            options += ['-b:a', quality_or_bitrate]
        options += ['-metadata', f'title={title}'] if title else []
        options += ['-metadata', f'artist={artist}'] if artist else []
        options += ['-metadata', f'album={album}'] if album else []
        options += ['-metadata', f'date={year}'] if year else []
        options += ['-metadata', f'track={track}'] if track else []
        options += ['-metadata', f'comment={comment}'] if comment else []
        return write_pcm_to_file(output_path, payload, samplerate, options)
def write_pcm_to_mp3 ( output_path : Path , payload : bytes , samplerate : int , quality_or_bitrate : Union [ int , str ] = 0 , title : str = None , artist : str = None , album : str = None , year : str = None , track : int = None , comment : str = None ) : options = [ '-c:a' , 'libmp3lame' ] if not ( quality_or_bitrate is None or isinstance ( quality_or_bitrate , ( int , str ) ) ) : raise TypeError ( f"quality_or_bitrate must one of type (int, str) or None, got " f"{type(quality_or_bitrate)}" ) if isinstance ( quality_or_bitrate , int ) : options += [ '-q:a' , str ( quality_or_bitrate ) ] elif isinstance ( quality_or_bitrate , str ) : options += [ '-b:a' , quality_or_bitrate ] options += [ '-metadata' , f'title={title}' ] if title else [ ] options += [ '-metadata' , f'artist={artist}' ] if artist else [ ] options += [ '-metadata' , f'album={album}' ] if album else [ ] options += [ '-metadata' , f'date={year}' ] if year else [ ] options += [ '-metadata' , f'track={track}' ] if track else [ ] options += [ '-metadata' , f'comment={comment}' ] if comment else [ ] return write_pcm_to_file ( output_path , payload , samplerate , options )
Write unsigned 8-bit audio data to an MP3 file.
Write unsigned 8 - bit audio data to an MP3 file .
"""
        Write unsigned 8-bit audio data to an MP3 file.

        :param output_path: path to write MP3 file
        :param payload: raw PCM samples
        :param samplerate: samplerate of the audio data
        :param quality_or_bitrate: if an integer, encode with this VBR quality
            preset, otherwise if a string (like '320k'), encode with CBR
        :param title: track name
        :param artist: track artist
        :param album: album name
        :param year: year created
        :param track: track number in album
        :param comment: comment string
        """
output_path
Path
path to write MP3 file
path to write MP3 file
payload
bytes
raw PCM samples
raw PCM samples
samplerate
int
samplerate of the audio data
samplerate of the audio data
quality_or_bitrate
Union[int, str]
if an integer, encode with this VBR quality
preset, otherwise if a string (like '320k'), encode with CBR
if an integer encode with this VBR quality preset otherwise if a string ( like ' 320k ' ) encode with CBR
title
str
None
artist
str
None
album
str
None
year
str
None
track
int
track number in album
track number in album
comment
str
None