import pytube as pt def second_to_timecode(x: float) -> str: """Float x second to HH:MM:SS.DDD format.""" hour, x = divmod(x, 3600) minute, x = divmod(x, 60) second, x = divmod(x, 1) millisecond = int(x * 1000.) return '%.2d:%.2d:%.2d,%.3d' % (hour, minute, second, millisecond) def download_from_youtube(youtube_link: str) -> str: yt = pt.YouTube(youtube_link) available_streams = yt.streams.filter(only_audio=True) print('available streams:') print(available_streams) stream = available_streams.first() # , audio_codec='wav' stream.download(filename="audio.wav") return "audio.wav"