*

Demark

  • **
  • 26 posts
Voice Search
« on: April 09, 2021, 08:05:18 AM »
Add Voice Search On Osclass If Possible.

*

MB Themes

Re: Voice Search
« Reply #1 on: April 09, 2021, 09:40:42 AM »
@Demark
Thanks for your feedback ;)
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Ajit Sahane

  • ****
  • 175 posts
  • https://bestclassifiedsusa.com
Re: Voice Search
« Reply #2 on: January 13, 2025, 04:32:34 AM »
Any update for Voice Search...?   Its important nowadays. Kindly workout in this.

*

MB Themes

Re: Voice Search
« Reply #3 on: January 13, 2025, 08:24:50 PM »
No plans for that, dont find it much useful, but expect its just about javascript.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

mwindey

  • *****
  • 484 posts
Re: Voice Search
« Reply #4 on: January 15, 2025, 07:19:04 PM »
For epsilon theme:

css/style.css add:

Code: [Select]
#voiceSearchButton {
background-color: #f9f9f9;
border: none;
padding: 10px;
cursor: pointer;
font-size: 20px;
margin-right: 15px; /* Add distance between microphone button and search button here */
position: relative;
}

/* Tooltip style */
.tooltip {
position: absolute;
bottom: calc(100% + 15px); /* Place tooltip above button with extra margin */
left: 50%; /* Center tooltip horizontally */
transform: translateX(-50%);
background-color: #00bdd6;
color: #f9f9f9;
padding: 5px 10px;
border-radius: 5px;
font-size: 12px;
 white-space: nowrap;
 z index: 10;
 display: none; /* Hide default */
}

.voice-search-container {
 position: relative;
 display: inline block;
}

In main.php ad:
Code: [Select]
<form action="<?php echo osc_base_url(true); ?>" method="GET" class="nocsrf" id="searchForm">
  <input type="hidden" name="page" value="search" />
 
  <?php if ($location_cookie['success'] == true) { ?>
    <?php if ($location_cookie['fk_i_city_id'] > 0) { ?>
      <input type="hidden" class="loc-inp" name="sCity" value="<?php echo osc_esc_html($location_cookie['fk_i_city_id']); ?>" />
    <?php } elseif ($location_cookie['fk_i_region_id'] > 0) { ?>
      <input type="hidden" class="loc-inp" name="sRegion" value="<?php echo osc_esc_html($location_cookie['fk_i_region_id']); ?>" />
    <?php } elseif ($location_cookie['fk_c_country_code'] <> '') { ?>
      <input type="hidden" class="loc-inp" name="sCountry" value="<?php echo osc_esc_html($location_cookie['fk_c_country_code']); ?>" />
    <?php ?>
  <?php ?>
 
  <div class="input-box picker pattern">
    <input type="text" id="searchInput" name="sPattern" class="pattern" placeholder="<?php _e('Enter keyword...''epsilon'); ?>" value="<?php echo osc_esc_html(Params::getParam('sPattern')); ?>" autocomplete="on" />
    <i class="clean fas fa-times-circle"></i>
    <div class="results">
      <div class="loaded"></div>
      <div class="default"><?php eps_default_pattern_content(); ?></div>
    </div>
  </div>
 
  <!-- Voice Search Button with Tooltip -->
  <div class="voice-search-container">
    <button type="button" id="voiceSearchButton" aria-label="<?php _e('Voice Search''epsilon'); ?>">🎤</button>
    <div id="tooltip" class="tooltip">Listening...</div>
  </div>

  <button class="btn" type="submit" aria-label="<?php _e('Search''epsilon'); ?>"><i class="fa fa-search"></i><span><?php _e('Search''epsilon'); ?></span></button>
</form>

<script>
// Check if the browser supports speech recognition
if ('SpeechRecognition' in window || 'webkitSpeechRecognition' in window) {
  const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
  recognition.lang = 'en-US'; // Default language (American English)
  recognition.continuous = false; // Stop after one search
  recognition.interimResults = false; // No interim results

  const tooltip = document.getElementById('tooltip');
  const voiceSearchButton = document.getElementById('voiceSearchButton');

  // Start speech recognition when clicking the button
  voiceSearchButton.addEventListener('click', function () {
    tooltip.style.display = 'block'; // Show the tooltip
    recognition.start();
  });

  // When speech recognition returns results
  recognition.onresult = function (event) {
    const spokenWords = event.results[0][0].transcript;
    document.getElementById('searchInput').value = spokenWords;
    tooltip.style.display = 'none'; // Hide the tooltip
    document.getElementById('searchForm').submit(); // Automatically submit the form
  };

  // Hide the tooltip on error or when recognition ends
  recognition.onerror = recognition.onend = function () {
    tooltip.style.display = 'none';
  };
} else {
  alert('Your browser does not support speech recognition.');
}
</script>
<?php eps_get_latest_searches(20?>
« Last Edit: Yesterday at 10:05:47 PM by mwindey »

*

Ajit Sahane

  • ****
  • 175 posts
  • https://bestclassifiedsusa.com
Re: Voice Search
« Reply #5 on: January 16, 2025, 02:55:26 PM »
any live test demo..?

*

mwindey

  • *****
  • 484 posts
Re: Voice Search
« Reply #6 on: January 16, 2025, 05:10:28 PM »
I don't like to put my domain because of too many fake users... I would say backup your originals, test it and if it doesn't work enough for you put your BU file back. It's just a small effort :-)

*

tomi327

  • ***
  • 67 posts
Re: Voice Search
« Reply #7 on: Yesterday at 02:28:10 AM »
« Last Edit: Yesterday at 03:09:43 AM by tomi327 »