Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issues #1

Open
T-Rebecca opened this issue Nov 1, 2018 · 1 comment
Open

issues #1

T-Rebecca opened this issue Nov 1, 2018 · 1 comment

Comments

@T-Rebecca
Copy link

python3 dataset_utils.py
File "dataset_utils.py", line 187
else:
^
SyntaxError: invalid syntax

    sliced.export(audioset_dir+'/Audio/yvid__'+r['id']+'__'+str(label)+'.wav', format="wav")
    else:
print(yid+': Already exists!')

if name == "main":
#logger = configure_logging()
main()

@ruohoruotsi
Copy link

I had to re-indent the file, as the formatting got screwed up somehow and python is sensitive to indentation levels. My code looks like:

def download_youtube_audio(yid, start, end, label):
    ydl_opts = {
        'format': 'bestaudio/best',
        'postprocessors': [{
            'key': 'FFmpegExtractAudio',
            'preferredcodec': 'wav',
            'preferredquality': '192',
        }],
    }

    youtube_url_base = 'https://youtu.be'

    if label is not None:
        ydl_opts["outtmpl"] = audioset_dir + '/Audio/yvid__%(id)s__' + str(label) + '.%(ext)s'

        # Join URL elements as in `youtu.be/m55Fx5rDh8g?start=50&end=60`
        youtube_url = youtube_url_base + '/' + yid + '?start=' + str(start) + '&end=' + str(end)

        r = None

        with youtube_dl.YoutubeDL(ydl_opts) as ydl:
            ydl.download([youtube_url])
            r = ydl.extract_info(youtube_url, download=False)

        audiofile = AudioSegment.from_wav(audioset_dir + '/Audio/yvid__' + r['id'] + '__' + str(label) + '.wav')
        sliced = audiofile[int(float(row[1]) * 1000):int(float(row[2]) * 1000)]
        sliced.export(audioset_dir + '/Audio/yvid__' + r['id'] + '__' + str(label) + '.wav', format="wav")

    else:
        print(yid + ': Already exists!')

Now I need to find the main() which looks to be missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants