N.Achyuth Reddy commited on
Commit
abcaf3c
·
verified ·
1 Parent(s): 85472d8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -20
app.py CHANGED
@@ -1,5 +1,10 @@
1
  import streamlit as st
2
- import requests
 
 
 
 
 
3
 
4
  # Constants
5
  TITLE = "AgriTure"
@@ -12,22 +17,25 @@ Hope this will be a Successful Project!!!
12
  """
13
  MEMBERSHIP_PRICE_USD = 10.0
14
 
15
- # Hoodpay API endpoint (example)
16
- HOODPAY_API_URL = "https://hoodpay.com/api/payment"
17
-
18
- # Function to create a new payment request
19
- def create_payment_request(currency):
20
- headers = {
21
- "Authorization": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjEzMTY5IiwiZXhwIjoyMDIzMTYxNzg0fQ.2CyFNaoQAki3t2VzExk_aLJdd3WVkrVQuRRL5x8BV0A",
22
- "Content-Type": "application/json"
 
 
23
  }
24
- data = {
25
- "amount": MEMBERSHIP_PRICE_USD,
26
- "currency": currency,
27
- # Add any additional parameters required by the Hoodpay API
28
- }
29
- response = requests.post(HOODPAY_API_URL, headers=headers, json=data)
30
- return response.json()
 
31
 
32
  # Streamlit UI
33
  st.title(TITLE)
@@ -44,10 +52,17 @@ for message in st.session_state.messages:
44
  textinput = st.chat_input("Ask AgriTure anything...")
45
 
46
  # Payment and Membership Subscription
47
- if st.button("Subscribe with Hoodpay"):
48
- payment_info = create_payment_request('HOODPAY_SUPPORTED_CURRENCY')
49
- # Process the payment information and display to the user
50
- st.write("Payment processing details:", payment_info)
 
 
 
 
 
 
 
51
 
52
  # React to user input
53
  if textinput:
@@ -63,5 +78,11 @@ if textinput:
63
  with st.chat_message("assistant", avatar='🌿'):
64
  st.markdown(response)
65
 
 
 
 
 
 
 
66
  # Add assistant response to chat history
67
  st.session_state.messages.append({"role": "assistant", "content": response})
 
1
  import streamlit as st
2
+ from coinbase_commerce.client import Client
3
+ from gtts import gTTS
4
+ import os
5
+
6
+ # Initialize Coinbase Commerce client
7
+ client = Client(api_key='YOUR_API_KEY')
8
 
9
  # Constants
10
  TITLE = "AgriTure"
 
17
  """
18
  MEMBERSHIP_PRICE_USD = 10.0
19
 
20
+ # Function to create a charge for membership
21
+ def create_membership_charge(currency):
22
+ charge_data = {
23
+ 'name': 'Monthly Membership',
24
+ 'description': 'Access to premium features for one month',
25
+ 'local_price': {
26
+ 'amount': MEMBERSHIP_PRICE_USD,
27
+ 'currency': currency
28
+ },
29
+ 'pricing_type': 'fixed_price'
30
  }
31
+ charge = client.charge.create(**charge_data)
32
+ return charge
33
+
34
+ # Function to convert text to speech using gTTS
35
+ def text_to_speech(text, lang='en'):
36
+ tts = gTTS(text=text, lang=lang, slow=False)
37
+ tts.save("response.mp3")
38
+ return "response.mp3"
39
 
40
  # Streamlit UI
41
  st.title(TITLE)
 
52
  textinput = st.chat_input("Ask AgriTure anything...")
53
 
54
  # Payment and Membership Subscription
55
+ if st.button("Subscribe with Bitcoin"):
56
+ charge = create_membership_charge('BTC')
57
+ bitcoin_address = charge['addresses']['bitcoin']
58
+ st.write("Please send Bitcoin to the following address:", bitcoin_address)
59
+ st.write("Your membership will be activated once the payment is confirmed.")
60
+
61
+ if st.button("Subscribe with Litecoin"):
62
+ charge = create_membership_charge('LTC')
63
+ litecoin_address = charge['addresses']['litecoin']
64
+ st.write("Please send Litecoin to the following address:", litecoin_address)
65
+ st.write("Your membership will be activated once the payment is confirmed.")
66
 
67
  # React to user input
68
  if textinput:
 
78
  with st.chat_message("assistant", avatar='🌿'):
79
  st.markdown(response)
80
 
81
+ # Convert AI response to speech
82
+ speech_file = text_to_speech(response)
83
+
84
+ # Play the generated speech
85
+ st.audio(speech_file, format="audio/mp3")
86
+
87
  # Add assistant response to chat history
88
  st.session_state.messages.append({"role": "assistant", "content": response})