-
Notifications
You must be signed in to change notification settings - Fork 1
/
textanalysis.py
89 lines (58 loc) · 2.08 KB
/
textanalysis.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# -*- coding: utf-8 -*-
"""TextAnalysis.ipynb
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/drive/1CLkAMHQopSBOhPO1uj12UXeV30gm4sIX
"""
!pip install pytube
import pytube
#extracting audio from video youtube link
video= 'https://www.youtube.com/shorts/f2bz0-HS7Ho'
data=pytube.YouTube(video)
audio=data.streams.get_audio_only()
A=audio.download()
Aud=A[9:]
Aud
!pip install --force-reinstall git+https://github.com/openai/whisper.git -q
import whisper
#Loading large model
model1 = whisper.load_model('large')
decode_options={"language":"english"}
text = model1.transcribe(Aud,word_timestamps= True,verbose=True)
!pip install tqdm
from google.colab import drive
drive.mount("/content/drive/")
!pip install nltk language_tool_python PyDictionary
file_path = "transcribed_text.txt"
with open(file_path, "w") as file:
file.write(str(text))
import language_tool_python
def check_grammar(text):
tool = language_tool_python.LanguageTool('en-US')
matches = tool.check(text)
for match in matches:
print(match)
check_grammar(text)
!pip install -q -U google-generativeai
import pathlib
import textwrap
import google.generativeai as genai
from IPython.display import display
from IPython.display import Markdown
def to_markdown(text):
text = text.replace('•', ' *')
return Markdown(textwrap.indent(text, '> ', predicate=lambda _: True))
# Used to securely store your API key
from google.colab import userdata
import os
os.environ['GOOGLE_API_KEY']="AIzaSyAvVS3R25nh7cENucohKlkJiOuxscENNtA"
genai.configure(api_key=os.environ['GOOGLE_API_KEY'])
for m in genai.list_models():
if 'generateContent' in m.supported_generation_methods:
print(m.name)
model = genai.GenerativeModel('gemini-1.0-pro-latest')
# Commented out IPython magic to ensure Python compatibility.
# %%time
# response = model.generate_content("Suggest some feedback and improvements, positives, negatives, better action words in short to the person who is ansering this interview question"+ str(text) )
to_markdown(response.text)
response.prompt_feedback