Update app.py
Browse files
app.py
CHANGED
|
@@ -1,42 +1,42 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import
|
| 3 |
-
|
| 4 |
|
| 5 |
-
#
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
# Load the input audio (your voice)
|
| 10 |
-
waveform, sample_rate = torchaudio.load(input_audio)
|
| 11 |
|
| 12 |
-
#
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
# Synthesize the song text using your cloned voice
|
| 17 |
-
# Combine with the musical style of the selected musician
|
| 18 |
-
synthesized_song = f"Singing '{song_text}' with your voice in the style of {musician_style}."
|
| 19 |
-
|
| 20 |
-
return synthesized_song
|
| 21 |
|
| 22 |
-
#
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
-
#
|
| 41 |
-
demo.launch()
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import pdfplumber
|
| 3 |
+
import pandas as pd
|
| 4 |
|
| 5 |
+
# Function to process PDF and classify transactions
|
| 6 |
+
def process_pdf(file):
|
| 7 |
+
if file is None:
|
| 8 |
+
return "No file uploaded."
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
# Extract text from the uploaded PDF
|
| 11 |
+
with pdfplumber.open(file.name) as pdf:
|
| 12 |
+
text = "\n".join([page.extract_text() for page in pdf.pages if page.extract_text()])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
+
# Extract transactions (Modify based on statement format)
|
| 15 |
+
lines = text.split("\n")
|
| 16 |
+
transactions = [line for line in lines if any(char.isdigit() for char in line)]
|
| 17 |
+
|
| 18 |
+
# Convert to DataFrame
|
| 19 |
+
df = pd.DataFrame([line.split()[:3] for line in transactions], columns=["Date", "Description", "Amount"])
|
| 20 |
+
|
| 21 |
+
# Classification function (Modify as needed)
|
| 22 |
+
def classify_transaction(description):
|
| 23 |
+
categories = {
|
| 24 |
+
"Grocery": ["Walmart", "Kroger", "Whole Foods"],
|
| 25 |
+
"Dining": ["McDonald's", "Starbucks", "Chipotle"],
|
| 26 |
+
"Bills": ["Verizon", "AT&T", "Con Edison"],
|
| 27 |
+
"Entertainment": ["Netflix", "Spotify", "Amazon Prime"],
|
| 28 |
+
"Transport": ["Uber", "Lyft", "MetroCard"],
|
| 29 |
+
}
|
| 30 |
+
for category, keywords in categories.items():
|
| 31 |
+
if any(keyword in description for keyword in keywords):
|
| 32 |
+
return category
|
| 33 |
+
return "Other"
|
| 34 |
+
|
| 35 |
+
# Apply classification
|
| 36 |
+
df["Category"] = df["Description"].apply(classify_transaction)
|
| 37 |
|
| 38 |
+
return df # Display the table
|
|
|
|
| 39 |
|
| 40 |
+
# Gradio Interface
|
| 41 |
+
app = gr.Interface(fn=process_pdf, inputs=gr.File(type="file"), outputs="dataframe", title="Bank Statement Classifier")
|
| 42 |
+
app.launch()
|