pm6six commited on
Commit
de0992d
·
verified ·
1 Parent(s): d1f9c3c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -36
app.py CHANGED
@@ -1,42 +1,42 @@
1
  import gradio as gr
2
- import torchaudio
3
- from transformers import pipeline
4
 
5
- # Load a voice cloning or TTS model
6
- # Here we use a placeholder for a voice cloning model like Tortoise-TTS
7
- # You can replace this with your preferred library
8
- def voice_cloning(input_audio, song_text, musician_style):
9
- # Load the input audio (your voice)
10
- waveform, sample_rate = torchaudio.load(input_audio)
11
 
12
- # Process the waveform to extract voice features (using Tortoise-TTS or similar)
13
- # This is a placeholder - you'll need to use a real voice cloning pipeline here
14
- cloned_voice = f"Processed your voice for song '{song_text}' in the style of {musician_style}"
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
- # Create a Gradio interface
23
- with gr.Blocks() as demo:
24
- gr.Markdown("### Voice Cloning & Singing in a Musician's Style")
25
-
26
- with gr.Row():
27
- input_audio = gr.Audio(label="Upload Your Voice", type="filepath")
28
- song_text = gr.Textbox(label="Enter Song Lyrics", placeholder="Enter the song lyrics here...")
29
- musician_style = gr.Textbox(label="Enter Musician's Style", placeholder="e.g., Adele, Ed Sheeran, etc.")
30
-
31
- output = gr.Textbox(label="Synthesized Song")
32
-
33
- generate_button = gr.Button("Generate")
34
- generate_button.click(
35
- voice_cloning,
36
- inputs=[input_audio, song_text, musician_style],
37
- outputs=output
38
- )
 
 
 
 
 
 
39
 
40
- # Launch the app
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()