#๐Ÿ”’ trying to use the yt api to convert videos to text

91 messages ยท Page 1 of 1 (latest)

sick blade
#

first used whisper but that was too slow for the server and now really struggeling to use the yt api

hollow emberBOT
#

@sick blade

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

sick blade
#

!paste

hollow emberBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

sick blade
#

things above are just connecting to the server with ssh and db

#

not all arguments converted during string formatting right now im stuck on this but running from one error to another for like the past 6 hours

runic arrow
#

What error are you facing? You haven't mentioned that

sick blade
#

not all arguments converted during string formatting right

#

so it won t be converted to a str

runic arrow
#

You are facing issue during query generation?

sick blade
#

yeah

runic arrow
#

Can you share the error?

#

Also please share the generated query if possible so that we can debug a bit easier

sick blade
sick blade
#
 cur.execute("""
                                      INSERT INTO testytapi (test_id, testYTAPI)
                                      VALUES (%s, %s)
                                      ON CONFLICT (test_id)
                                      DO UPDATE SET
                                          testYTAPI = EXCLUDED.testYTAPI;
                                  """, ( testYTAPI))
#

need it to be a text tho

runic arrow
#

I guess a primary key can't be string

#

I don't know if I am wrong

sick blade
lapis bison
#

The ( testYTAPI) at the end is suppose to be a 2-tuple of the test_id and the testYTAPI, not just the testYTAPI.

runic arrow
#

Yeah I think this must be the issue

lapis bison
#

Like (test_id, testYTAPI). But i don't know where the value for test_id should come from.

lapis bison
#

Ah, test_id is an automatic column.

sick blade
#

see example above

lapis bison
#

You should be able to leave it out in the INSERT then. So:

INSERT INTO testytapi (testYTAPI)
VALUES (%s)
``` etc etc
#

Then you need a 1-tuple at the end to match the single %s.

#

But (testYTAPI) is not a 1-tuple, it's just testYTAPI (they're just brackets).

#

You want (testYTAPI,) - note the comma, which makes the value in the brackets a tuple.

sick blade
#

you mean the comma after """?

lapis bison
#

No, you want to change (testYTAPI) to (testYTAPI,)

sick blade
lapis bison
#

See how you've got a 5-tuple in the earlier INSERT? It's a list of values separated by commas.

#

So (1,2) is a 2-tuple. () is a 0-tuple. But (1) is just... 1. You need (1,) to make it a tuple.

#

This is because we use brackets for grouping, and the comma disambiguates from that.

sick blade
lapis bison
#

This 1-tuple stuff is Python stuff.

#

But filling in the SQL parameters - you need the same number of values as the %ss in the query.

#

You'll need to learn some SQL.

sick blade
sick blade
#

oh it is not defined

#

should be testYTAPI

#

lemme check my db really quick ๐Ÿ™‚

lapis bison
#

Well, it's looking better. See what's in the table now.

sick blade
#

some seem short compared to whisper think im gonna run it a bit longer and see

lapis bison
#

You should probably get rid of the except Exception as e:. It catches too much. You should only catch what you expect to happen. Other exceptions are bugs, to be investigated.

#

If you hadn't had that, the traceback would have identified the line the error occured on for you.

sick blade
#

alright give me 5 min wanna complete my script to see if it prints longer texts

#

this is whisper so you can see it is way shorter than whisper but maybe it was still loading

sick blade
#

thank you for the help tho could have never guessed i needed a , ๐Ÿ˜Š

lapis bison
#

Yeah. That kind of fiddly syntax detail can be really hard to find.

solar musk
#

doesn't YT do automatic transcriptions? Or is that not part of the API?

sick blade
solar musk
#

oh, so you want to use another model to make alternate transcripts?

lapis bison
#

It might just be a subtitle track in the video.

solar musk
#

I've noticed that the automatic transcripts can be...off at times

sick blade
solar musk
#

can't you just use the provided transcripts and then use an LLM on that?

#

I believe there are models that can demonstrably do that already

sick blade
solar musk
#

I don't know what this is

sick blade
sick blade
solar musk
#

what are the IDs? is it possible that there's no speech in those given segments?

sick blade
#

chnaged the 3d quary a bit and one return statement

solar musk
#

looks a bit off nevertheless

lapis bison
#

I think the early rows (12..21) are an artifact of a bug since fixed.

solar musk
#

sounds plausible

sick blade
#

๐Ÿคทโ€โ™‚๏ธ

lapis bison
#

It's the wrong variable name you fixed earlier.

sick blade
lapis bison
#

This:

except Exception as e:
            print(f"Er trad een fout op bij het ophalen van de transcript voor video {video_id}: {e}")
            return f"Fout opgetreden: {e}"

returns the NameError from your mistaken full_transcript variable as though it was the transcription.

sick blade
#

but i don t have full_transcript anywhere

lapis bison
#

Yeah. But you did when rows 12..21 were inserted.

sick blade
#

oh

#

the biggest thing i wonder is why the texts are so short

lapis bison
#

Look at the video itself in a browser? See if it's got almost no subtitles?

sick blade
lapis bison
#

I'm going AFK. Good luck.

hollow emberBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.