Skip to content

Instantly share code, notes, and snippets.

View Younes-Charfaoui's full-sized avatar
🎨
Focusing

Younes Charfaoui Younes-Charfaoui

🎨
Focusing
View GitHub Profile
@Younes-Charfaoui
Younes-Charfaoui / ArrangeTheString.java
Created December 28, 2017 12:24
This is a solution for the Arrage the Strings problem
package Challegne;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class ArrangeTheString {
private static List<String> word;
@Younes-Charfaoui
Younes-Charfaoui / MainActivity.java
Created May 1, 2018 14:46
The List view of Adda
package com.example.helloworld;
import android.app.Activity;
import android.os.Bundle;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
public class MainActivity extends Activity {
package com.charfaoui.tpevaluation;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
if (!SpeechRecognizer.isRecognitionAvailable(this)) {
Toast.makeText(
this,
R.string.no_recognition_available,
Toast.LENGTH_LONG
).show()
}
private fun askSpeechInput() {
val 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, "Hi speak something");
startActivityForResult(intent, REQ_CODE_SPEECH_INPUT);
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == REQUEST_SPEECH_RECOGNIZER && resultCode == Activity.RESULT_OK) {
val results = data?.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS)
Log.d("TAG-R", results?.toString())
}
}
override fun onReadyForSpeech(params: Bundle?) {
Log.d(TAG, "onReadyForSpeech")
}
override fun onRmsChanged(rmsdB: Float) {
Log.d(TAG, "onRmsChanged")
}
override fun onBufferReceived(buffer: ByteArray?) {
Log.d(TAG, "onBufferReceived")
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
val textToSpeech = TextToSpeech(this, this)
textToSpeech.setOnUtteranceProgressListener(object : UtteranceProgressListener() {
override fun onDone(utteranceId: String?) {
//do whatever you want when TTS finish speaking.
}
override fun onError(utteranceId: String?) {
//do whatever you want if TTS makes an error.
}