0% found this document useful (0 votes)
7 views6 pages

Update Version of Code in Asep Project

The document provides an updated version of the Smart Travel Assistance Application (STAA) code, highlighting necessary libraries to be downloaded in red. It outlines the functionalities of the application, including offline translation, text-to-speech, PDF integration, improved UI, detailed report generation, offline map interface, distance calculation, and shortest path calculation. The document also invites feedback on the desired format for the updated code.

Uploaded by

gauravshende5052
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views6 pages

Update Version of Code in Asep Project

The document provides an updated version of the Smart Travel Assistance Application (STAA) code, highlighting necessary libraries to be downloaded in red. It outlines the functionalities of the application, including offline translation, text-to-speech, PDF integration, improved UI, detailed report generation, offline map interface, distance calculation, and shortest path calculation. The document also invites feedback on the desired format for the updated code.

Uploaded by

gauravshende5052
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

The below code is update version of current so the red words given below information

iin red are library that should be download so please check and try to run the update
code is in last and red sentence is tip so please note that also that it should be added or
not ---------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------

import tkinter as tk

from tkinter import ttk, scrolledtext, filedialog, messagebox

import pyttsx3

import folium

import os

from math import radians, cos, sin, sqrt, atan2

from reportlab.lib.pagesizes import letter

from reportlab.pdfgen import canvas

import argostranslate.package

import argostranslate.translate

import webbrowser

# Load Argos Translate for offline translation

argostranslate.package.update_package_index()

installed_languages = argostranslate.package.get_installed_packages()

# Initialize TTS

engine = pyttsx3.init()

def text_to_speech(text):

engine.say(text)

engine.runAndWait()

def translate_text(text, src_lang="en", dest_lang="fr"):


return argostranslate.translate.translate(text, src_lang, dest_lang)

def haversine(lat1, lon1, lat2, lon2):

R = 6371 # Radius of Earth in km

dlat = radians(lat2 - lat1)

dlon = radians(lon2 - lon1)

a = sin(dlat / 2) ** 2 + cos(radians(lat1)) * cos(radians(lat2)) * sin(dlon / 2) ** 2

c = 2 * atan2(sqrt(a), sqrt(1 - a))

return R * c

def generate_pdf_report(text, filename="Travel_Report.pdf"):

c = canvas.Canvas(filename, pagesize=letter)

c.drawString(100, 750, "Travel Assistance Report")

c.drawString(100, 730, text)

c.save()

messagebox.showinfo("Success", f"PDF Report saved as {filename}")

def open_map():

map_center = [20.5937, 78.9629] # India center

m = folium.Map(location=map_center, zoom_start=5)

map_file = "map.html"

m.save(map_file)

webbrowser.open(map_file)

def ask_query():

user_input = user_entry.get()

chat_area.insert(tk.END, f"You: {user_input}\n", "user")

response = "Processing..."
if "translate" in user_input:

response = translate_text(user_input, "en", "fr")

elif "distance" in user_input:

response = f"Distance: {haversine(19.076, 72.8777, 28.7041, 77.1025):.2f} km" #


Mumbai to Delhi

elif "map" in user_input:

open_map()

response = "Map opened in browser!"

chat_area.insert(tk.END, f"STAA: {response}\n", "bot")

text_to_speech(response)

user_entry.delete(0, tk.END)

# GUI Setup

root = tk.Tk()

root.title("Smart Travel Assistance Application")

root.geometry("600x500")

frame = ttk.Frame(root, padding="10")

frame.pack(fill=tk.BOTH, expand=True)

chat_area = scrolledtext.ScrolledText(frame, wrap=tk.WORD, width=70, height=20)

chat_area.pack(pady=5)

chat_area.tag_config("user", foreground="blue")

chat_area.tag_config("bot", foreground="green")

user_entry = ttk.Entry(frame, width=50)

user_entry.pack(side=tk.LEFT, padx=5, pady=5)


send_button = ttk.Button(frame, text="Ask", command=ask_query)

send_button.pack(side=tk.RIGHT, padx=5, pady=5)

pdf_button = ttk.Button(frame, text="Generate Report", command=lambda:


generate_pdf_report(chat_area.get("1.0", tk.END)))

pdf_button.pack(side=tk.BOTTOM, pady=5)

root.mainloop()

--------------------------------------------------------------------------------------------------------------
-----------------------------------RUN THIS CODE------------------------------------------------------

Here’s a breakdown of the Smart Travel Assistance Application (STAA) code, including
all the major sections and their functionalities:

1. Offline Translation

• Feature: Translates text between languages without requiring an internet


connection.

• Implementation: Uses a local translation model or a preloaded dictionary-


based approach.

• Libraries: transformers (for small local models) or deep_translator with an


offline dictionary.

2. Text-to-Speech (TTS)

• Feature: Converts text into speech for accessibility and ease of communication.

• Implementation: Uses a TTS engine like pyttsx3, which works offline.

• Libraries: pyttsx3 (offline speech synthesis).

3. PDF Integration (City Data & Adding New Cities)

• Feature: Allows users to view city data from PDFs and add new city information.

• Implementation: Reads PDFs using PyMuPDF (fitz) and allows appending data
dynamically.
• Libraries: PyMuPDF for PDF reading and writing.

4. Improved UI

• Feature: A user-friendly and visually appealing interface for easy navigation.

• Implementation: Built using Tkinter or PyQt for smooth user interaction.

• Libraries: Tkinter (lightweight) or PyQt (more advanced UI options).

5. Detailed PDF Report Generation

• Feature: Generates a comprehensive PDF report based on travel data.

• Implementation: Uses reportlab to create structured reports.

• Libraries: reportlab for PDF generation.

6. Offline Map Interface

• Feature: Displays maps without an internet connection.

• Implementation: Uses preloaded map tiles (e.g., from OpenStreetMap).

• Libraries: folium (for interactive maps) or gmaps with local caching.

7. Distance Calculation (Haversine / Euclidean Distance)

• Feature: Calculates the distance between two points.

• Implementation: Uses the Haversine formula for real-world distances and


Euclidean distance for simpler scenarios.

• Libraries: geopy.distance or custom formula.

8. Shortest Path Calculation

• Feature: Finds the shortest route between locations.

• Implementation: Uses Dijkstra’s Algorithm or A (A-star)* for pathfinding.

• Libraries: networkx for graph-based shortest path computation.


Would you like the updated code in a specific format (Python, Tkinter UI, PyQt, etc.)? Let
me know how you want it structured! 🚀

You might also like