Skip to content

Commit 5789088

Browse files
committed
full working ai avatar
1 parent 0d4e252 commit 5789088

24 files changed

+124
-54
lines changed

Backend/Narrator.py

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,16 @@ def extract_image_name(questions):
8888
return important_topics
8989

9090

91-
@router.get("/api5")
92-
async def process_message(message: str):
91+
@router.get("/narrator")
92+
async def process_message():
9393
print("Giving promt to OPENAI...")
94-
file_path = 'Local_Storage/Generated_Files/Summarised_Notes/module1_summarized.txt'
94+
file_path = 'Local_Storage\Generated_Files\gpt_promt_sum\module2.txt'
9595
extracted_text = extract_text_from_file(file_path)
9696
narrate = extract_important_topics(extracted_text)
9797

9898
print(narrate)
9999
# Save topics to topics.txt
100-
with open('Local_Storage/Generated_Files/Narrator_Output/m1.txt', 'w', encoding='utf-8') as file:
100+
with open('Local_Storage/Generated_Files/narration.txt', 'w', encoding='utf-8') as file:
101101
file.write(narrate)
102102

103103
image_name=extract_image_name(narrate)
@@ -116,26 +116,35 @@ async def process_message(message: str):
116116

117117

118118

119-
narrate = extract_important_topics(message)
120-
with open('Local_Storage/Generated_Files/narration.txt', 'w', encoding='utf-8') as file:
121-
file.write(narrate)
122-
print(narrate)
123-
with open('Local_Storage/Generated_Files/response.txt', 'w') as file:
124-
# Truncate the file to remove its contents
125-
file.truncate()
126-
shutil.rmtree("images")
127-
128-
129-
image_name=extract_image_name(narrate)
130-
image_list = image_name.splitlines()
131-
132-
# Create a directory to store the images
133-
os.makedirs("images", exist_ok=True)
134-
os.chdir("images")
135-
136-
# Process the paragraphs and search for related images
137-
print(image_list)
138-
process_paragraphs(image_list)
139-
140-
# Return to the parent directory
141-
os.chdir("..")
119+
while(True):
120+
with open('Local_Storage/Generated_Files/response.txt', 'r',encoding='utf-8') as file:
121+
content = file.read()
122+
if len(content)==0:
123+
continue
124+
else:
125+
if content == "understood":
126+
break
127+
if content[0]==".":
128+
narrate = extract_important_topics(content)
129+
with open('Local_Storage/Generated_Files/narration.txt', 'w', encoding='utf-8') as file:
130+
file.write(narrate)
131+
print(narrate)
132+
with open('Local_Storage/Generated_Files/response.txt', 'w') as file:
133+
# Truncate the file to remove its contents
134+
file.truncate()
135+
shutil.rmtree("images")
136+
137+
138+
image_name=extract_image_name(narrate)
139+
image_list = image_name.splitlines()
140+
141+
# Create a directory to store the images
142+
os.makedirs("images", exist_ok=True)
143+
os.chdir("images")
144+
145+
# Process the paragraphs and search for related images
146+
print(image_list)
147+
process_paragraphs(image_list)
148+
149+
# Return to the parent directory
150+
os.chdir("..")
-57 Bytes
Binary file not shown.
465 Bytes
Binary file not shown.
38 Bytes
Binary file not shown.

Backend/speech_text.py

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
import os
55
import azure.cognitiveservices.speech as speechsdk
66
from fastapi import UploadFile, APIRouter
7-
7+
import sounddevice as sd
8+
import soundfile as sf
89
# Create an instance of APIRouter
910
router = APIRouter()
1011

@@ -15,6 +16,22 @@
1516
speech_config = speechsdk.SpeechConfig(subscription=speech_key, region=service_region)
1617
speech_recognizer = speechsdk.SpeechRecognizer(speech_config=speech_config)
1718

19+
def record_audio(duration, output_file):
20+
# Set the sample rate and number of channels for recording
21+
sample_rate = 44100 # CD quality audio
22+
channels = 2 # Stereo audio
23+
24+
# Start recording audio
25+
recording = sd.rec(int(duration * sample_rate), samplerate=sample_rate, channels=channels)
26+
27+
print("Recording audio...")
28+
sd.wait() # Wait until recording is finished
29+
30+
# Save the recorded audio to a file
31+
sf.write(output_file, recording, sample_rate)
32+
33+
print(f"Audio saved to: {output_file}")
34+
1835
def speech_to_text(audio_file):
1936
audio_config = speechsdk.audio.AudioConfig(filename=audio_file)
2037
speech_recognizer = speechsdk.SpeechRecognizer(speech_config=speech_config, audio_config=audio_config)
@@ -28,13 +45,23 @@ def speech_to_text(audio_file):
2845

2946
return transcript
3047

31-
@router.post("/api5")
32-
async def convert_speech_to_text(file: UploadFile):
33-
file_path = f"audio_files/{file.filename}"
34-
os.makedirs("audio_files", exist_ok=True)
35-
with open(file_path, "wb") as audio:
36-
audio.write(await file.read())
48+
@router.get("/api5")
49+
def convert_speech_to_text():
50+
print("recording..")
51+
duration = 5 # Recording duration in seconds
52+
output_file = "Local_Storage/Audio/recorded_audio.wav" # Output file name
53+
54+
record_audio(duration, output_file)
55+
file_path = "Local_Storage/Audio/recorded_audio.wav"
56+
3757

3858
transcript = speech_to_text(file_path)
59+
transcript="."+transcript
60+
61+
# Save the transcript to a text file
62+
transcript_file = "Local_Storage/Generated_Files/response.txt"
63+
with open(transcript_file, "w") as f:
64+
f.write(transcript)
3965

40-
return {"transcript": transcript}
66+
67+
return transcript

Backend/texttoAIvideo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
@router.get('/api6')
88
async def get_text_from_file():
9-
with open('input.txt', 'r') as file:
9+
with open('Local_Storage/Generated_Files/narration.txt', 'r') as file:
1010
file_text = file.read(200)
1111
return JSONResponse(content={"blendData": file_text})
1212

861 KB
Binary file not shown.
Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
Hello, let's talk about digital electronics and specifically about combinational and sequential circuits. Digital circuits are of two types: combinational circuits and sequential circuits. Combinational circuits only depend on the present inputs, while sequential circuits depend on both the present and past inputs.
1+
Hello! Today we will be discussing digital electronics and specifically focusing on combinational and sequential circuits, as well as adder circuits. Do you have any questions before we begin?
22

3-
To design a digital circuit, we follow a procedure that involves six steps: we start by stating the problem, then we determine the number of available input and required output variables, assign letter symbols to them, create a truth table that shows their relationship, simplify the Boolean function for each output, and finally draw the logic diagram.
3+
No? Okay, let's start. The output of a combinational circuit depends only on its present inputs, while the output of a sequential circuit depends on both its present and past inputs. Digital circuits are of two types: combinational circuits and sequential circuits.
44

5-
For the most basic arithmetic operation, addition, we use adder circuits. There are two types of adder circuits: half-adder and full-adder. The half-adder uses two-input NOR gates to add two binary digits, while the full-adder adds two bits and a carry, and outputs a sum bit and a carrying bit. We can realize a full-adder circuit using an XOR gate and two AND gates.
5+
Now let's move on to adder circuits. The most basic arithmetic operation is the addition of two binary digits. The logic gates accept signals from the inputs and generate signals to the outputs. They are called adder circuits, which are of two types: half-adder and full-adder.
66

7-
If we want to subtract one bit from another, we can use a half-subtractor or a full-subtractor. The full-subtractor is a combinational circuit with three inputs and two outputs, and we can realize it with XOR gates and AOI gates.
7+
The truth table and block diagram of a half-adder are shown below. Realization using AOI logic is possible using one X-OR gate and one AND gate as shown in Figure 7.3a. The full-adder circuit can be realized by using one gate and the other using a single AND gate. The full-adder circuit is a combinational circuit that performs the addition of three bits (two significant bits).
88

9-
If we want to add two binary numbers in parallel form, we use an n-bit parallel adder which consists of full adders connected in a chain. The carry-out of each full-adder is the carry-in to the next stage in a ripple carry adder. The subtraction of two binary numbers can be achieved by taking the 2's complement of one of them and adding it to the other.
9+
The Full-Adder adds the bits A and B and the carry-in C in and outputs the sum bit S. The Full-Adder adds the bit A and A and C in the previous column called the carry in C in, the carry out the other bit called the carrying-in-Cin.
1010

11-
We can speed up the addition process with a look-ahead-carry adder, which examines all the input bits simultaneously and generates the carry-in bits for all the stages simultaneously. The carry-in to each stage is the carry-out of the previous stage, and we get the following Boolean expressions for the final sum and carry outputs of the nth stage: Pn, Cn, P_, Pn-Cn-Sn, P-Sn, and C-Sn.
11+
And you can also use a half-subtractor as a combinational circuit that subtracts one bit from the other and produces the difference. It also has an output to specify if a 1 has been borrowed.
1212

13-
For code conversion, we use a logic circuit called a code converter that converts a bit-pattern representing numbers from one code to another code. For example, a 4-bit binary-to-Gray-code conversion circuit outputs a Gray-type code for a 4-bit binary input. We can also use a decoder to convert an N-bit-binary input code into M output lines, where only one output line is activated for each possible combination of inputs. Conversely, an encoder does the opposite of decoding, taking decimal digits and/or alphabetic characters and outputting the coded representations.
13+
An n-bit parallel adder is a digital circuit that adds two binary numbers in parallel form. It consists of full adders connected in a chain, with the output carry of each full-adder connected to the input carry of the next full-adder in the chain.
1414

15-
Finally, we discussed a magnitude comparator, which is a logic circuit that compares two quantities and gives an output signal indicating whether the two input quantities are equal or not. It compares the binary representations of the input quantities and gives the result of A=B, A>B, or A<B.
15+
The subtraction A - B can be done by taking the 2's complement of B and adding it to A. The subtracted bit is not valid until after the cumulative propagation of two full adders (FA, and FA), and so on. The total sum (the parallel output) of a 4-bit binary adder-subtractor is not.
16+
17+
The look-ahead-carry adder speeds up the process by eliminating this ripple carry delay. It examines all the input bits simultaneously and also generates the carry-in bits for all the stages simultaneously. The method of speeding up the addition process is based on the two additional functions of the full-adder, called the carry generate and carry-propagate functions.
18+
19+
Do you understand everything so far? Any questions or things you want me to explain more?
Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
Sure, a truth table is a tool used in logic to analyze the relationships between propositions. It consists of columns representing the different propositions and their possible truth values, as well as a final column representing the resulting truth value of the entire expression.
1+
Sure! A truth table is a way of representing the outcomes of logical expressions. It lists all possible combinations of input values and their corresponding output values. The input variables in a truth table are usually denoted as "P," "Q," and so on, while the output values are usually represented as "T" or "F" for true or false.
22

3-
For example, let's say we have two propositions, P and Q. Each proposition can have one of two possible truth values - true or false. We can use a truth table to analyze the different possible combinations of truth values for P and Q and determine the truth value of the logical expression P AND Q, which represents the conjunction of the two propositions.
3+
For example, let's consider the logical expression "P OR Q." The truth table for this expression would have two input columns, one for "P" and one for "Q," and one output column for the result of the expression. The truth table would list all possible combinations of "P" and "Q," and then determine whether the expression is true or false for each combination.
44

5-
So, we would start by creating a table with two columns, one for P and one for Q. Then, we would fill in each row with a different combination of truth values for P and Q - true/false, true/true, false/false, and false/true.
5+
So, for the "P OR Q" expression, the truth table would look like this:
66

7-
Next, we would add a third column representing the truth value of the expression P AND Q. To determine the truth value of this expression for each row, we would simply apply the AND operator to the truth values of P and Q for that row.
7+
P Q P OR Q
8+
-------------
9+
T T T
10+
T F T
11+
F T T
12+
F F F
813

9-
After completing all the rows, we would have a complete truth table showing all the possible truth values for the expression P AND Q, given different truth values for P and Q. This can help us see patterns and relationships between different propositions, and is a powerful tool in understanding logical statements.
10-
11-
Does that help clarify the concept of truth tables for you?
14+
Does that make sense? Do you have any questions or need further clarification?

Python_Code/recorder.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import sounddevice as sd
2+
import soundfile as sf
3+
4+
def record_audio(duration, output_file):
5+
# Set the sample rate and number of channels for recording
6+
sample_rate = 44100 # CD quality audio
7+
channels = 2 # Stereo audio
8+
9+
# Start recording audio
10+
recording = sd.rec(int(duration * sample_rate), samplerate=sample_rate, channels=channels)
11+
12+
print("Recording audio...")
13+
sd.wait() # Wait until recording is finished
14+
15+
# Save the recorded audio to a file
16+
sf.write(output_file, recording, sample_rate)
17+
18+
print(f"Audio saved to: {output_file}")
19+
20+
# Example usage
21+
duration = 5 # Recording duration in seconds
22+
output_file = "Local_Storage/Audio/recorded_audio.wav" # Output file name
23+
24+
record_audio(duration, output_file)

0 commit comments

Comments
 (0)