This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class MyFirebaseMessagingService extends FirebaseMessagingService { | |
| private static final String TAG = "MyFirebaseMsgService"; | |
| private int id=32489; | |
| /** | |
| * Called when message is received. | |
| * | |
| * @param remoteMessage Object representing the message received from Firebase Cloud Messaging. | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
| package="com.kuarkdijital.samam"> | |
| <uses-permission android:name="android.permission.INTERNET" /> | |
| <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | |
| <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | |
| <uses-permission android:name="android.permission.BLUETOOTH"/> | |
| <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // DialogFlow SDK depencies | |
| implementation 'ai.api:sdk:2.0.7@aar' | |
| implementation 'ai.api:libai:1.6.12' | |
| // Java v2 | |
| implementation 'com.google.cloud:google-cloud-dialogflow:0.67.0-alpha' | |
| implementation 'io.grpc:grpc-okhttp:1.15.1' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private fun initAsisstant() { | |
| try { | |
| val stream = resources.openRawResource(R.raw.asistan) | |
| val credentials = GoogleCredentials.fromStream(stream) | |
| val projectId = (credentials as ServiceAccountCredentials).projectId | |
| val settingsBuilder = SessionsSettings.newBuilder() | |
| val sessionsSettings = | |
| settingsBuilder.setCredentialsProvider(FixedCredentialsProvider.create(credentials)).build() | |
| client = SessionsClient.create(sessionsSettings) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class RequestTask : AsyncTask<Void, Void, DetectIntentResponse> { | |
| var activity: Activity? = null | |
| private var session: SessionName? = null | |
| private var sessionsClient: SessionsClient? = null | |
| private var queryInput: QueryInput? = null | |
| constructor(activity: Activity,session:SessionName,sessionsClient: SessionsClient,queryInput: QueryInput){ | |
| this.activity=activity |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private fun sendMicrophoneMessage(view:View){ | |
| val intent: Intent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH) | |
| intent.putExtra( | |
| RecognizerIntent.EXTRA_LANGUAGE_MODEL, | |
| RecognizerIntent.LANGUAGE_MODEL_FREE_FORM | |
| ) | |
| intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault()) | |
| intent.putExtra( | |
| RecognizerIntent.EXTRA_PROMPT, | |
| getString(R.string.speech_prompt) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private fun initAsisstantVoice() { | |
| asistan_voice= TextToSpeech(applicationContext,object : TextToSpeech.OnInitListener { | |
| override fun onInit(status: Int) { | |
| if (status!=TextToSpeech.ERROR){ | |
| asistan_voice?.language=Locale("tr") | |
| } | |
| } | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun onResult(response: DetectIntentResponse?) { | |
| try { | |
| if (response != null) { | |
| var botReply:String="" | |
| if(response.queryResult.fulfillmentText==" ") | |
| botReply= response.queryResult.fulfillmentMessagesList[0].text.textList[0].toString() | |
| else | |
| botReply= response.queryResult.fulfillmentText | |
| appendText(botReply, BOT) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private fun appendText(message: String, type: Int) { | |
| val layout: FrameLayout | |
| when (type) { | |
| USER -> layout = appendUserText() | |
| BOT -> layout = appendBotText() | |
| else -> layout = appendBotText() | |
| } | |
| layout.isFocusableInTouchMode = true | |
| linear_chat.addView(layout) | |
| val tv = layout.findViewById<TextView>(R.id.chatMsg) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { | |
| super.onActivityResult(requestCode, resultCode, data) | |
| when(requestCode){ | |
| SPEECH_INPUT->{ | |
| if(resultCode== Activity.RESULT_OK | |
| && data !=null){ | |
| val result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS) | |
| edittext.text=Editable.Factory.getInstance().newEditable(result[0]) | |
| sendMessage(send) | |
| } |
OlderNewer