Advertisement:

Author Topic: {New Plugin Idea} Search By Voice  (Read 614 times)

_carlison

  • Full Member
  • ***
  • Posts: 134
{New Plugin Idea} Search By Voice
« on: October 02, 2017, 10:45:42 am »
Hello ,

I am planning for "search by voice" plugin, but when i have use with theme then it was not work. so any one can help me.

I have paste my code in this topic. so please help me

Quote
<?php

/*
  Plugin Name: Search By Voice
  Plugin URI: http://osclass.org
  Description: Search by Voice
  Version: 1.0.1
  Author: Carlison
  Author Email: *******
  Author URI: http://osclass.org
  Plugin update URI: search-by-voice
  Short Name: search-by-voice
 */

function search_by_voice_install() {
    //nothing for now
}

function search_by_voice_uninstall() {
    //nothing for now
}

function search_by_voice() {
    ?>

<style>
  .speech {border: 1px solid #DDD; width: 300px; padding: 0; margin: 0}
  .speech input {border: 0; width: 240px; display: inline-block; height: 30px;}
  .speech img {float: right; width: 40px }
</style>

<!-- Search Form -->
<form id="labnol" method="get" action="<?php echo osc_base_url() ; ?>index.php?page=search">
  <div class="speech">
    <input type="text" name="q" id="transcript" placeholder="Speak" />
    <img onclick="startDictation()" src="<?php echo osc_base_url() ; ?>/oc-content/plugins/search_by_voice/search.gif" />
  </div>
</form>

<!-- HTML5 Speech Recognition API -->
<script>
  function startDictation() {

    if (window.hasOwnProperty('webkitSpeechRecognition')) {

      var recognition = new webkitSpeechRecognition();

      recognition.continuous = false;
      recognition.interimResults = false;

      recognition.lang = "en-US";
      recognition.start();

      recognition.onresult = function(e) {
        document.getElementById('transcript').value
                                 = e.results[0][0].transcript;
        recognition.stop();
        document.getElementById('labnol').submit();
      };

      recognition.onerror = function(e) {
        recognition.stop();
      }

    }
  }
</script>
  <?php
}

function search_by_voice_config() {
    osc_admin_render_plugin('search_by_voice/help.php');
}
osc_add_hook(osc_plugin_path(__FILE__) . "_configure", 'search_by_voice_config');
osc_add_hook('search_by_voice_form', 'search_by_voice');
osc_register_plugin(osc_plugin_path(__FILE__), 'search_by_voice_install');
osc_add_hook(osc_plugin_path(__FILE__) . "_uninstall", 'search_by_voice_uninstall');

Please suggest me good solution then i will upload this plugin in market osclass
« Last Edit: October 02, 2017, 11:02:06 am by _Carlison »

Liath

  • issues
  • Hero Member
  • *
  • Posts: 1346
  • </html> the end is always near
Re: {New Plugin Idea} Search By Voice
« Reply #1 on: October 02, 2017, 10:05:11 pm »
please be more specific...


Quote from: _Carlison
when i have use with theme then it was not work

_carlison

  • Full Member
  • ***
  • Posts: 134
Re: {New Plugin Idea} Search By Voice
« Reply #2 on: October 03, 2017, 10:23:05 am »
please be more specific...


Quote from: _Carlison
when i have use with theme then it was not work

Liath , I mean when i have use this plugin in bender and osclasswizard theme (because i am using only these 2 themes) then its not redirect to search page and microphone is display blocked . but when i have use on localhost and use as HTML Code then it work perfectly.  So please suggest me what i do or if you will modify in this plugin then please help me. then we will create new other plugins together.

And main thing microphone was not unblocked after using this new plugin.
Thanks

_carlison

  • Full Member
  • ***
  • Posts: 134
Re: {New Plugin Idea} Search By Voice
« Reply #3 on: October 17, 2017, 11:17:25 am »
Hi Guys,

Please help me for this plugin, its really nice for all osclass users