pyresearch commited on
Commit
6ab2a14
1 Parent(s): f4725db

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -8
app.py CHANGED
@@ -17,6 +17,9 @@ APP_ID_DALLE = 'dall-e'
17
  MODEL_ID_DALLE = 'dall-e-3'
18
  MODEL_VERSION_ID_DALLE = 'dc9dcb6ee67543cebc0b9a025861b868'
19
 
 
 
 
20
  # Set your Clarifai credentials for Text-to-Speech (TTS)
21
  PAT_TTS = 'bfdeb4029ef54d23a2e608b0aa4c00e4'
22
  USER_ID_TTS = 'openai'
@@ -24,20 +27,29 @@ APP_ID_TTS = 'tts'
24
  MODEL_ID_TTS = 'openai-tts-1'
25
  MODEL_VERSION_ID_TTS = 'fff6ce1fd487457da95b79241ac6f02d'
26
 
 
 
 
 
 
 
27
  # Streamlit app
28
  st.title("Smart Crop Advisor")
29
 
 
30
  # Inserting logo
31
  st.image("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAAA9lBMVEUALlb///8ALFUAKFIAGEoAIk8AJlEAG0y4wcsALlUAKlQAJ1IAJFDY3+W0v8oFNVwAHk0AEkjr7vEAH03P1t1AW3itvMhdc4v09vjs8PNrg5JodYoAD0jg5uv3+fpKiz0VOF0yS2uAkaJtoWHG0Nigr71nfJN0h5sAC0VFiTeaqLY6VnVIYn5UbIZ6jqKGmasZQmYiR2pcl05ffIeXtaBonlyFr4J9qXNKaYaeqrh1i5m2y8KXsaPN4sWvzKebsa+fvp7K28eMpqC70LiSpavU39yRu4nS4tOKr4uqw7KqxKd3kZh5p3GbsLI+hy3j7eKUtJaLq5fPgWHGAAARqklEQVR4nO1de3+iuBqmgYAFFBQVnV1RK+gqXnuml5mds3PfmW47PbPf/8ucgCQEiAqWTqvl+WN/OwqYJ++b95Y3lOMKFChQoMBB4BSA2Aen3n+eZCy5A+wgAk4PmWq2kR8uz9QAuy95FjgFDxpqfMU+Ozz38RXYhqOXXv6W8HlN2fMaTd54mO08ABw5vRdA8M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rag+snKC01Hqhfc6TN8f3Hx4fry740NH0BaNVsZXgqyaY0CVfLe9Fcp2bZdmsxnmhB1skBWvC4NPvmRnPwoolDAUBrzSQnBGU1lr6oBZOpOZXZ7+1Z7e7vl5Sqy3mhm2Hna/CDvbY2CAFVJ0DO/sHE7eKgLCBIMeo8iD1e8PQl1+1v3+CwO/1ibkAscEnaW1Ao1LfDEKFSwwNGgUOYCBQr8EhyescncmvAoo3hEHNyAM6NgmM8tT4i9/lDQIf2FzsMSxx4oCBYo8MR4mI4egIaneAHU9vsPyWcU2IQD0NQH4jkzfM5jK1AgbxT6XiB/PIZWPSdNfU5jOSg8n4l7PiM5RBSz9+h4aDpY4Ilx7PI7dn5HT/AJ+B37lBYoUODF4NjNWbGj8EvxMqY7t/eYH/vqO3YciPz2HGbur+t/RGR9Ucoe9zwTnJ7uGDg4VGY0PN2L6Z/XHeB/dPjsChQoUOBF4P+xvGxHlRtZjAAAAABJRU5ErkJggg==", width=200)
 
 
 
 
32
 
33
- # Choose model type
34
- model_type = st.radio("Select Model Type", ["GPT-4 Vision", "DALL-E", "Text-to-Speech (TTS)"])
35
 
36
- # Input text prompt from the user
37
- raw_text = st.text_input("Enter a text prompt:", 'What is Smart Crop Adviser?')
38
 
39
- # File upload for image
40
- image_upload = st.file_uploader("Upload an image:", type=["jpg", "jpeg", "png"])
 
 
41
 
42
  # Button to generate result
43
  if st.button("Generate Result"):
@@ -65,7 +77,7 @@ if st.button("Generate Result"):
65
  version_id=MODEL_VERSION_ID_GPT4,
66
  inputs=[resources_pb2.Input(data=input_data_gpt4)]
67
  ),
68
- metadata=metadata_gpt4
69
  )
70
 
71
  # Check if the request was successful for GPT-4 Vision
@@ -79,8 +91,32 @@ if st.button("Generate Result"):
79
  if output_gpt4.HasField("image"):
80
  st.image(output_gpt4.image.base64, caption='Generated Image (GPT-4 Vision)', use_column_width=True)
81
  elif output_gpt4.HasField("text"):
 
82
  st.text(output_gpt4.text.raw)
83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  elif model_type == "DALL-E":
85
  # Set up gRPC channel for DALL-E
86
  channel_dalle = ClarifaiChannel.get_grpc_channel()
@@ -148,9 +184,13 @@ if st.button("Generate Result"):
148
  output_tts = post_model_outputs_response_tts.outputs[0].data
149
 
150
  # Display the result for Text-to-Speech (TTS)
 
 
 
151
  if output_tts.HasField("audio"):
152
  st.audio(output_tts.audio.base64, format='audio/wav')
153
 
 
154
  # Add the beautiful social media icon section
155
  st.markdown("""
156
  <div align="center">
@@ -173,4 +213,4 @@ st.markdown("""
173
  <img src="https://user-images.githubusercontent.com/34125851/226601355-ffe0b597-9840-4e10-bbef-43d6c74b5a9e.png" width="2%" alt="" /></a>
174
  </div>
175
  <hr>
176
- """, unsafe_allow_html=True)
 
17
  MODEL_ID_DALLE = 'dall-e-3'
18
  MODEL_VERSION_ID_DALLE = 'dc9dcb6ee67543cebc0b9a025861b868'
19
 
20
+
21
+
22
+ # Streamlit app
23
  # Set your Clarifai credentials for Text-to-Speech (TTS)
24
  PAT_TTS = 'bfdeb4029ef54d23a2e608b0aa4c00e4'
25
  USER_ID_TTS = 'openai'
 
27
  MODEL_ID_TTS = 'openai-tts-1'
28
  MODEL_VERSION_ID_TTS = 'fff6ce1fd487457da95b79241ac6f02d'
29
 
30
+ # Set up gRPC channel for Text-to-Speech (TTS)
31
+ channel_tts = ClarifaiChannel.get_grpc_channel()
32
+ stub_tts = service_pb2_grpc.V2Stub(channel_tts)
33
+ metadata_tts = (('authorization', 'Key ' + PAT_TTS),)
34
+ userDataObject_tts = resources_pb2.UserAppIDSet(user_id=USER_ID_TTS, app_id=APP_ID_TTS,)
35
+
36
  # Streamlit app
37
  st.title("Smart Crop Advisor")
38
 
39
+
40
  # Inserting logo
41
  st.image("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAAA9lBMVEUALlb///8ALFUAKFIAGEoAIk8AJlEAG0y4wcsALlUAKlQAJ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Channel.get_grpc_channel()
45
+ return channel_tts, channel_tts.metadata
46
 
 
 
47
 
 
 
48
 
49
+ # User input
50
+ model_type = st.selectbox("Select Model", ["GPT-4 Vision", "DALL-E", "Text-to-Speech (TTS)"])
51
+ raw_text = st.text_area("Enter Text")
52
+ image_upload = st.file_uploader("Upload Image", type=["jpg", "jpeg", "png"])
53
 
54
  # Button to generate result
55
  if st.button("Generate Result"):
 
77
  version_id=MODEL_VERSION_ID_GPT4,
78
  inputs=[resources_pb2.Input(data=input_data_gpt4)]
79
  ),
80
+ metadata=metadata_gpt4 # Use metadata directly in the gRPC request
81
  )
82
 
83
  # Check if the request was successful for GPT-4 Vision
 
91
  if output_gpt4.HasField("image"):
92
  st.image(output_gpt4.image.base64, caption='Generated Image (GPT-4 Vision)', use_column_width=True)
93
  elif output_gpt4.HasField("text"):
94
+ # Display the text result
95
  st.text(output_gpt4.text.raw)
96
 
97
+ # Convert text to speech and play the audio
98
+ stub_tts = service_pb2_grpc.V2Stub(channel_gpt4) # Use the same channel for TTS
99
+
100
+ tts_input_data = resources_pb2.Data()
101
+ tts_input_data.text.raw = output_gpt4.text.raw
102
+
103
+ tts_response = stub_tts.PostModelOutputs(
104
+ service_pb2.PostModelOutputsRequest(
105
+ user_app_id=userDataObject_tts,
106
+ model_id=MODEL_ID_TTS,
107
+ version_id=MODEL_VERSION_ID_TTS,
108
+ inputs=[resources_pb2.Input(data=tts_input_data)]
109
+ ),
110
+ metadata=metadata_gpt4 # Use the same metadata for TTS
111
+ )
112
+
113
+ # Check if the TTS request was successful
114
+ if tts_response.status.code == status_code_pb2.SUCCESS:
115
+ tts_output = tts_response.outputs[0].data
116
+ st.audio(tts_output.audio.base64, format='audio/wav')
117
+ else:
118
+ st.error(f"Text-to-Speech (TTS) API request failed: {tts_response.status.description}")
119
+
120
  elif model_type == "DALL-E":
121
  # Set up gRPC channel for DALL-E
122
  channel_dalle = ClarifaiChannel.get_grpc_channel()
 
184
  output_tts = post_model_outputs_response_tts.outputs[0].data
185
 
186
  # Display the result for Text-to-Speech (TTS)
187
+ if output_tts.HasField("text"):
188
+ st.text(output_tts.text.raw)
189
+
190
  if output_tts.HasField("audio"):
191
  st.audio(output_tts.audio.base64, format='audio/wav')
192
 
193
+
194
  # Add the beautiful social media icon section
195
  st.markdown("""
196
  <div align="center">
 
213
  <img src="https://user-images.githubusercontent.com/34125851/226601355-ffe0b597-9840-4e10-bbef-43d6c74b5a9e.png" width="2%" alt="" /></a>
214
  </div>
215
  <hr>
216
+ """, unsafe_allow_html=True)