Skip to content

Commit

Permalink
Update app.py
Browse files Browse the repository at this point in the history
removed audio related code
  • Loading branch information
ganeshkondaka authored Apr 19, 2024
1 parent 07784ca commit 7311159
Showing 1 changed file with 3 additions and 29 deletions.
32 changes: 3 additions & 29 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
from PIL import Image
import pickle

from IPython.display import HTML

import streamlit as st
from gtts import gTTS
from pydub import AudioSegment
from io import BytesIO


# Dictionary mapping class indices to class names
classes = { 0:'Speed limit (20km/h)',
Expand Down Expand Up @@ -83,18 +81,7 @@ def predict_traffic_sign(image):
# Predict using the loaded model
prediction = np.argmax(loaded_model.predict(image))
return classes[prediction]

# Function to convert text to audio and embed it in HTML
def text_to_audio(text, language='en'):
# Generate audio from text
tts = gTTS(text=text, lang=language, slow=False)
# Save audio as a temporary file
audio_path = "prediction_audio.mp3"
tts.save(audio_path)
# Create HTML audio player with autoplay
audio_html = f'<audio autoplay="autoplay" controls="controls"><source src="{audio_path}" type="audio/mp3"></audio>'
return audio_html



def main():
st.title("Traffic Sign Recognition App")
Expand All @@ -113,19 +100,6 @@ def main():
prediction = predict_traffic_sign(image)
st.write("Prediction:", prediction)

# audio_path = "D:/mine_/code files @@/pythonf/traffic_proj/outputaudio.mp3"

# # Display the audio player
# st.audio(audio_path, format='audio/mp3')

# Example usage
# Replace this with your prediction value
st.write("Prediction:", prediction)

# Convert prediction text to audio and display it
audio_html = text_to_audio(prediction)
st.write(HTML(audio_html))



if __name__ == '__main__':
Expand Down

0 comments on commit 7311159

Please sign in to comment.